From 799954653bfa8d79ec1d9f4559b91f7f20a84c2e Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Sat, 31 Aug 2019 22:33:41 -0500 Subject: [PATCH 01/27] WIP -QEMU support --- Tests/Cosmos.TestRunner.Core/Engine.Qemu.cs | 40 +++++++ Tests/Cosmos.TestRunner.Core/Engine.Run.cs | 3 + Tests/Cosmos.TestRunner.Core/Enums.cs | 3 +- .../DefaultEngineConfiguration.cs | 3 +- .../Cosmos.TestRunner.Full/TestKernelSets.cs | 32 +++--- source/Cosmos.Debug.Hosts/Qemu.cs | 105 ++++++++++++++++++ .../AD7.Impl/AD7Process.cs | 7 ++ .../VS/PropertyPages/ProfilePresets.cs | 4 + 8 files changed, 179 insertions(+), 18 deletions(-) create mode 100644 Tests/Cosmos.TestRunner.Core/Engine.Qemu.cs create mode 100644 source/Cosmos.Debug.Hosts/Qemu.cs diff --git a/Tests/Cosmos.TestRunner.Core/Engine.Qemu.cs b/Tests/Cosmos.TestRunner.Core/Engine.Qemu.cs new file mode 100644 index 000000000..86fb989e8 --- /dev/null +++ b/Tests/Cosmos.TestRunner.Core/Engine.Qemu.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Cosmos.Build.Common; +using Cosmos.Debug.DebugConnectors; +using Cosmos.Debug.Hosts; + +namespace Cosmos.TestRunner.Core +{ + partial class Engine + { + private void RunIsoInQemu(string iso, string harddisk, string workingDir) + { + if (!File.Exists(harddisk)) + { + throw new FileNotFoundException("Harddisk file not found!", harddisk); + } + + var xBochsConfig = Path.Combine(workingDir, "Kernel.bochsrc"); + var xParams = new Dictionary(); + + xParams.Add("ISOFile", iso); + xParams.Add(BuildPropertyNames.VisualStudioDebugPortString, @"Pipe: Cosmos\Serial"); + xParams.Add(BuildPropertyNames.EnableBochsDebugString, RunWithGDB.ToString()); + var xDebugConnector = new DebugConnectorPipeServer(DebugConnectorPipeServer.DefaultCosmosPipeName); + InitializeDebugConnector(xDebugConnector); + + var xQemu = new Qemu(xParams, RunWithGDB, harddisk) + { + OnShutDown = (a, b) => { mKernelRunning = false; }, + RedirectOutput = false, + LogError = s => OutputHandler.LogDebugMessage(s), + LogOutput = s => OutputHandler.LogDebugMessage(s) + }; + + HandleRunning(xDebugConnector, xQemu); + } + } +} diff --git a/Tests/Cosmos.TestRunner.Core/Engine.Run.cs b/Tests/Cosmos.TestRunner.Core/Engine.Run.cs index 1e5b651f0..8d1323f8e 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.Run.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.Run.cs @@ -60,6 +60,9 @@ namespace Cosmos.TestRunner.Core case RunTargetEnum.HyperV: RunTask("RunISO", () => RunIsoInHyperV(xIsoFile, xHarddiskPath)); break; + case RunTargetEnum.Qemu: + RunTask("RunISO", () => RunIsoInQemu(xIsoFile, xHarddiskPath, workingDirectory)); + break; default: throw new ArgumentOutOfRangeException("RunTarget " + configuration.RunTarget + " not implemented!"); } diff --git a/Tests/Cosmos.TestRunner.Core/Enums.cs b/Tests/Cosmos.TestRunner.Core/Enums.cs index 30d8a1c05..9e6d6fdcc 100644 --- a/Tests/Cosmos.TestRunner.Core/Enums.cs +++ b/Tests/Cosmos.TestRunner.Core/Enums.cs @@ -4,6 +4,7 @@ { Bochs, VMware, - HyperV + HyperV, + Qemu } } diff --git a/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs b/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs index 34eac84ed..22958fb1e 100644 --- a/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs +++ b/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs @@ -14,9 +14,10 @@ namespace Cosmos.TestRunner.Full { get { - yield return RunTargetEnum.Bochs; + //yield return RunTargetEnum.Bochs; //yield return RunTargetEnum.VMware; //yield return RunTargetEnum.HyperV; + yield return RunTargetEnum.Qemu; } } diff --git a/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs b/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs index 83ab5528e..53b65f68b 100644 --- a/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs +++ b/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs @@ -15,25 +15,25 @@ namespace Cosmos.TestRunner.Full // Stable kernel types: the ones that are stable and will run in AppVeyor public static IEnumerable GetStableKernelTypes() { - yield return typeof(BoxingTests.Kernel); - yield return typeof(Cosmos.Compiler.Tests.TypeSystem.Kernel); + //yield return typeof(BoxingTests.Kernel); + //yield return typeof(Cosmos.Compiler.Tests.TypeSystem.Kernel); yield return typeof(Cosmos.Compiler.Tests.Bcl.Kernel); - //yield return typeof(Cosmos.Compiler.Tests.Encryption.Kernel); - yield return typeof(Cosmos.Compiler.Tests.Exceptions.Kernel); - yield return typeof(Cosmos.Compiler.Tests.MethodTests.Kernel); - yield return typeof(Cosmos.Compiler.Tests.SingleEchoTest.Kernel); - yield return typeof(Cosmos.Kernel.Tests.Fat.Kernel); - yield return typeof(Cosmos.Kernel.Tests.IO.Kernel); - yield return typeof(SimpleStructsAndArraysTest.Kernel); - yield return typeof(Cosmos.Kernel.Tests.DiskManager.Kernel); + ////yield return typeof(Cosmos.Compiler.Tests.Encryption.Kernel); + //yield return typeof(Cosmos.Compiler.Tests.Exceptions.Kernel); + //yield return typeof(Cosmos.Compiler.Tests.MethodTests.Kernel); + //yield return typeof(Cosmos.Compiler.Tests.SingleEchoTest.Kernel); + //yield return typeof(Cosmos.Kernel.Tests.Fat.Kernel); + //yield return typeof(Cosmos.Kernel.Tests.IO.Kernel); + //yield return typeof(SimpleStructsAndArraysTest.Kernel); + //yield return typeof(Cosmos.Kernel.Tests.DiskManager.Kernel); - //yield return typeof(KernelGen3.Boot); + ////yield return typeof(KernelGen3.Boot); - yield return typeof(GraphicTest.Kernel); - /* Please see the notes on the kernel itself before enabling it */ - //yield return typeof(ConsoleTest.Kernel); - /* This is a bit slow and works only because ring check is disabled to decide if leave it enabled */ - yield return typeof(MemoryOperationsTest.Kernel); + //yield return typeof(GraphicTest.Kernel); + ///* Please see the notes on the kernel itself before enabling it */ + ////yield return typeof(ConsoleTest.Kernel); + ///* This is a bit slow and works only because ring check is disabled to decide if leave it enabled */ + //yield return typeof(MemoryOperationsTest.Kernel); } } } diff --git a/source/Cosmos.Debug.Hosts/Qemu.cs b/source/Cosmos.Debug.Hosts/Qemu.cs new file mode 100644 index 000000000..64f6681b8 --- /dev/null +++ b/source/Cosmos.Debug.Hosts/Qemu.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; +using Cosmos.Build.Common; + +namespace Cosmos.Debug.Hosts +{ + public class Qemu : Host + { + private static Process qemuProcess; + + private string harddiskFile; + + public bool RedirectOutput = false; + + public Action LogOutput; + + public Action LogError; + + public Qemu(Dictionary aParams, bool aUseGDB, string aHarddisk = null) + : base(aParams, aUseGDB) + { + if (String.IsNullOrWhiteSpace(aHarddisk)) + { + harddiskFile = Path.Combine(CosmosPaths.Build, @"VMWare\Workstation\Filesystem.vmdk"); + } + else + { + harddiskFile = aHarddisk; + } + } + + public override void Start() + { + qemuProcess = new Process(); + ProcessStartInfo qemuStartInfo = qemuProcess.StartInfo; + qemuStartInfo.FileName = QemuSupport.QemuExe.FullName; + + string biosPath = "."; + string isoPath = ""; + int memorySize = 32; + qemuStartInfo.Arguments = $"-L {biosPath} -cdrom {isoPath} -m {memorySize}"; + qemuStartInfo.CreateNoWindow = true; + if (RedirectOutput) + { + if (LogOutput == null) + { + throw new Exception("No LogOutput handler specified!"); + } + + if (LogError == null) + { + throw new Exception("No LogError handler specified!"); + } + } + + qemuProcess.EnableRaisingEvents = true; + qemuProcess.Exited += ExitCallback; + qemuProcess.Start(); + if (RedirectOutput) + { + qemuProcess.BeginErrorReadLine(); + qemuProcess.BeginOutputReadLine(); + } + } + + private void ExitCallback(object sender, EventArgs e) + { + if (OnShutDown != null) + { + try + { + OnShutDown(sender, e); + } + catch + { + } + } + } + + public override void Stop() + { + if (null != qemuProcess) + { + try + { + qemuProcess.Kill(); + } + catch + { + } + } + + Cleanup(); + } + + private void Cleanup() + { + OnShutDown(this, null); + qemuProcess.Exited -= ExitCallback; + } + } +} diff --git a/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs b/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs index ad218501d..eb7fe567d 100644 --- a/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs +++ b/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs @@ -566,6 +566,13 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl case LaunchType.HyperV: mHost = new HyperV(mDebugInfo, false); break; + case LaunchType.Qemu: + if (!QemuSupport.QemuEnabled) + { + throw new Exception("The Qemu emulator doesn't seem to be installed on this machine."); + } + mHost = new Qemu(mDebugInfo, xUseGDB); + break; default: throw new Exception("Invalid Launch value: '" + mLaunch + "'."); } diff --git a/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/ProfilePresets.cs b/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/ProfilePresets.cs index a91c3d875..9f9e6e5fb 100644 --- a/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/ProfilePresets.cs +++ b/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/ProfilePresets.cs @@ -17,6 +17,10 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages } Add("IntelEdison", "Intel Edison Serial boot"); Add("HyperV", "Hyper-V"); + if (QemuSupport.QemuEnabled) + { + Add("Qemu", "Qemu"); + } } } } From 3e259028940f98ad623714c8898cb8ff628994d3 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Tue, 3 Sep 2019 15:05:50 -0500 Subject: [PATCH 02/27] Qemu test runner work --- Tests/Cosmos.TestRunner.Core/Engine.Qemu.cs | 11 +++-- Tests/Cosmos.TestRunner.Core/Engine.cs | 1 - .../RunConfiguration.cs | 5 +++ .../Cosmos.TestRunner.Full/TestKernelSets.cs | 32 +++++++------- source/Cosmos.Debug.Hosts/Qemu.cs | 42 ++++++++++++++----- 5 files changed, 58 insertions(+), 33 deletions(-) diff --git a/Tests/Cosmos.TestRunner.Core/Engine.Qemu.cs b/Tests/Cosmos.TestRunner.Core/Engine.Qemu.cs index 86fb989e8..91681cfa2 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.Qemu.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.Qemu.cs @@ -17,13 +17,12 @@ namespace Cosmos.TestRunner.Core throw new FileNotFoundException("Harddisk file not found!", harddisk); } - var xBochsConfig = Path.Combine(workingDir, "Kernel.bochsrc"); - var xParams = new Dictionary(); + var xParams = new Dictionary + { + {BuildPropertyNames.IsoFileString, iso} + }; - xParams.Add("ISOFile", iso); - xParams.Add(BuildPropertyNames.VisualStudioDebugPortString, @"Pipe: Cosmos\Serial"); - xParams.Add(BuildPropertyNames.EnableBochsDebugString, RunWithGDB.ToString()); - var xDebugConnector = new DebugConnectorPipeServer(DebugConnectorPipeServer.DefaultCosmosPipeName); + var xDebugConnector = new DebugConnectorPipeClient("Cosmos\\Serial"); InitializeDebugConnector(xDebugConnector); var xQemu = new Qemu(xParams, RunWithGDB, harddisk) diff --git a/Tests/Cosmos.TestRunner.Core/Engine.cs b/Tests/Cosmos.TestRunner.Core/Engine.cs index 815c6ec04..18092ee8e 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.cs @@ -105,7 +105,6 @@ namespace Cosmos.TestRunner.Core foreach (var xTarget in RunTargets) { yield return new RunConfiguration(isElf: true, runTarget: xTarget); - //yield return new RunConfiguration(isElf: false, runTarget: xTarget); } } } diff --git a/Tests/Cosmos.TestRunner.Core/RunConfiguration.cs b/Tests/Cosmos.TestRunner.Core/RunConfiguration.cs index 5331b9bae..e01656b8f 100644 --- a/Tests/Cosmos.TestRunner.Core/RunConfiguration.cs +++ b/Tests/Cosmos.TestRunner.Core/RunConfiguration.cs @@ -9,6 +9,11 @@ { IsELF = isElf; RunTarget = runTarget; + + if (runTarget == RunTargetEnum.Qemu) + { + IsELF = false; + } } } } diff --git a/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs b/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs index 53b65f68b..83ab5528e 100644 --- a/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs +++ b/Tests/Cosmos.TestRunner.Full/TestKernelSets.cs @@ -15,25 +15,25 @@ namespace Cosmos.TestRunner.Full // Stable kernel types: the ones that are stable and will run in AppVeyor public static IEnumerable GetStableKernelTypes() { - //yield return typeof(BoxingTests.Kernel); - //yield return typeof(Cosmos.Compiler.Tests.TypeSystem.Kernel); + yield return typeof(BoxingTests.Kernel); + yield return typeof(Cosmos.Compiler.Tests.TypeSystem.Kernel); yield return typeof(Cosmos.Compiler.Tests.Bcl.Kernel); - ////yield return typeof(Cosmos.Compiler.Tests.Encryption.Kernel); - //yield return typeof(Cosmos.Compiler.Tests.Exceptions.Kernel); - //yield return typeof(Cosmos.Compiler.Tests.MethodTests.Kernel); - //yield return typeof(Cosmos.Compiler.Tests.SingleEchoTest.Kernel); - //yield return typeof(Cosmos.Kernel.Tests.Fat.Kernel); - //yield return typeof(Cosmos.Kernel.Tests.IO.Kernel); - //yield return typeof(SimpleStructsAndArraysTest.Kernel); - //yield return typeof(Cosmos.Kernel.Tests.DiskManager.Kernel); + //yield return typeof(Cosmos.Compiler.Tests.Encryption.Kernel); + yield return typeof(Cosmos.Compiler.Tests.Exceptions.Kernel); + yield return typeof(Cosmos.Compiler.Tests.MethodTests.Kernel); + yield return typeof(Cosmos.Compiler.Tests.SingleEchoTest.Kernel); + yield return typeof(Cosmos.Kernel.Tests.Fat.Kernel); + yield return typeof(Cosmos.Kernel.Tests.IO.Kernel); + yield return typeof(SimpleStructsAndArraysTest.Kernel); + yield return typeof(Cosmos.Kernel.Tests.DiskManager.Kernel); - ////yield return typeof(KernelGen3.Boot); + //yield return typeof(KernelGen3.Boot); - //yield return typeof(GraphicTest.Kernel); - ///* Please see the notes on the kernel itself before enabling it */ - ////yield return typeof(ConsoleTest.Kernel); - ///* This is a bit slow and works only because ring check is disabled to decide if leave it enabled */ - //yield return typeof(MemoryOperationsTest.Kernel); + yield return typeof(GraphicTest.Kernel); + /* Please see the notes on the kernel itself before enabling it */ + //yield return typeof(ConsoleTest.Kernel); + /* This is a bit slow and works only because ring check is disabled to decide if leave it enabled */ + yield return typeof(MemoryOperationsTest.Kernel); } } } diff --git a/source/Cosmos.Debug.Hosts/Qemu.cs b/source/Cosmos.Debug.Hosts/Qemu.cs index 64f6681b8..f40b1c34f 100644 --- a/source/Cosmos.Debug.Hosts/Qemu.cs +++ b/source/Cosmos.Debug.Hosts/Qemu.cs @@ -11,7 +11,11 @@ namespace Cosmos.Debug.Hosts { private static Process qemuProcess; - private string harddiskFile; + private string _harddiskFile; + + private string _isoFile; + + private string _debugPortString; public bool RedirectOutput = false; @@ -24,25 +28,43 @@ namespace Cosmos.Debug.Hosts { if (String.IsNullOrWhiteSpace(aHarddisk)) { - harddiskFile = Path.Combine(CosmosPaths.Build, @"VMWare\Workstation\Filesystem.vmdk"); + _harddiskFile = Path.Combine(CosmosPaths.Build, @"VMWare\Workstation\Filesystem.vmdk"); } else { - harddiskFile = aHarddisk; + _harddiskFile = aHarddisk; } + + if (aParams.ContainsKey(BuildPropertyNames.IsoFileString)) + { + _isoFile = aParams[BuildPropertyNames.IsoFileString]; + } + + _debugPortString = "Cosmos\\Serial"; } public override void Start() { qemuProcess = new Process(); - ProcessStartInfo qemuStartInfo = qemuProcess.StartInfo; + var qemuStartInfo = qemuProcess.StartInfo; qemuStartInfo.FileName = QemuSupport.QemuExe.FullName; - string biosPath = "."; - string isoPath = ""; - int memorySize = 32; - qemuStartInfo.Arguments = $"-L {biosPath} -cdrom {isoPath} -m {memorySize}"; - qemuStartInfo.CreateNoWindow = true; + string xQemuArguments = "-m 128"; + xQemuArguments += $" -cdrom {_isoFile}"; + + if (!string.IsNullOrWhiteSpace(_harddiskFile)) + { + xQemuArguments += $" -hda {_harddiskFile}"; + } + + if (!string.IsNullOrWhiteSpace(_debugPortString)) + { + xQemuArguments += $" -chardev pipe,path=\\\\Cosmos\\Serial,id=Cosmos -device isa-serial,chardev=Cosmos"; + } + + xQemuArguments += " -boot d"; + + qemuStartInfo.Arguments = xQemuArguments; if (RedirectOutput) { if (LogOutput == null) @@ -82,7 +104,7 @@ namespace Cosmos.Debug.Hosts public override void Stop() { - if (null != qemuProcess) + if (qemuProcess != null) { try { From da3ca1fe027e5b50b40e27805bb0ff06849ace07 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Sun, 6 Oct 2019 21:52:54 -0500 Subject: [PATCH 03/27] Use enums for LaunchType --- source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs b/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs index eb7fe567d..4e86d79eb 100644 --- a/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs +++ b/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs @@ -309,13 +309,11 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl string xPortType = xParts[0].ToLower(); string xPortParam = xParts[1].ToLower(); - var xLaunch = mDebugInfo[BuildPropertyNames.LaunchString]; - OutputText("Starting debug connector."); switch (xPortType) { case "pipe:": - if (xLaunch == "HyperV") + if (mLaunch == LaunchType.HyperV || mLaunch == LaunchType.Qemu) { mDbgConnector = new DebugConnectorPipeClient(xPortParam); } @@ -325,7 +323,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl } break; case "serial:": - if (xLaunch == "IntelEdison") + if (mLaunch == LaunchType.IntelEdison) { mDbgConnector = new DebugConnectorEdison(xPortParam, Path.ChangeExtension(mDebugInfo["ISOFile"], ".bin")); } @@ -336,7 +334,6 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl break; default: throw new Exception("No debug connector found for port type '" + xPortType + "'"); - } mDbgConnector.SetConnectionHandler(DebugConnectorConnected); mDbgConnector.CmdBreak += new Action(DbgCmdBreak); From ec36f1cbb07f290ede5dd1f1ccf19b86001effac Mon Sep 17 00:00:00 2001 From: Quajak Date: Fri, 4 Sep 2020 22:53:12 +0200 Subject: [PATCH 04/27] Merge remote-tracking branch 'origin/master' From e62eae14145ed1fbed92ca013fafdaa27133f5e6 Mon Sep 17 00:00:00 2001 From: Quajak Date: Mon, 7 Sep 2020 00:23:27 +0200 Subject: [PATCH 05/27] Added plugs for Convert.ToString Fixed int.ToString("x") --- .../Cosmos.Compiler.Tests.Bcl/Kernel.cs | 1 + .../System/ConvertTests.cs | 23 +++++++ .../Cosmos.System2_Plugs/System/Int32Impl.cs | 5 ++ .../System/ParseNumbersImpl.cs | 68 +++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs create mode 100644 source/Cosmos.System2_Plugs/System/ParseNumbersImpl.cs diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Kernel.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Kernel.cs index a566becf6..a1e35d8ca 100644 --- a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Kernel.cs +++ b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/Kernel.cs @@ -39,6 +39,7 @@ namespace Cosmos.Compiler.Tests.Bcl DelegatesTest.Execute(); EventsTest.Execute(); RandomTests.Execute(); + ConvertTests.Execute(); // System.Collections HashtableTest.Execute(); diff --git a/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs new file mode 100644 index 000000000..09ab43962 --- /dev/null +++ b/Tests/Kernels/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs @@ -0,0 +1,23 @@ +using Cosmos.TestRunner; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Cosmos.Compiler.Tests.Bcl.System +{ + public static class ConvertTests + { + public static void Execute() + { + Assert.AreEqual("1010", Convert.ToString(10, 2), "Convert.ToString(int, 2) works"); + Assert.AreEqual("12", Convert.ToString(10, 8), "Convert.ToString(int, 8) works"); + Assert.AreEqual("10", Convert.ToString(10, 10), "Convert.ToString(int, 10) works"); + Assert.AreEqual("A", Convert.ToString(10, 16), "Convert.ToString(int, 16) works"); + Assert.AreEqual("11000100000", Convert.ToString(1568, 2), "Convert.ToString(int, 2) works"); + Assert.AreEqual("3040", Convert.ToString(1568, 8), "Convert.ToString(int, 8) works"); + Assert.AreEqual("1568", Convert.ToString(1568, 10), "Convert.ToString(int, 10) works"); + Assert.AreEqual("620", Convert.ToString(1568, 16), "Convert.ToString(int, 16) works"); + + } + } +} diff --git a/source/Cosmos.System2_Plugs/System/Int32Impl.cs b/source/Cosmos.System2_Plugs/System/Int32Impl.cs index 0c65a0b35..b9ccbce72 100644 --- a/source/Cosmos.System2_Plugs/System/Int32Impl.cs +++ b/source/Cosmos.System2_Plugs/System/Int32Impl.cs @@ -20,6 +20,11 @@ namespace Cosmos.System_Plugs.System { string result = ""; + if(aThis == 0) + { + result = "0"; + } + while (aThis != 0) { if ((aThis % 16) < 10) diff --git a/source/Cosmos.System2_Plugs/System/ParseNumbersImpl.cs b/source/Cosmos.System2_Plugs/System/ParseNumbersImpl.cs new file mode 100644 index 000000000..1b712789f --- /dev/null +++ b/source/Cosmos.System2_Plugs/System/ParseNumbersImpl.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Cosmos.Common.Extensions; +using IL2CPU.API.Attribs; + +namespace Cosmos.System_Plugs.System +{ + [Plug(TargetName = "System.ParseNumbers, System.Private.CoreLib")] + class ParseNumbersImpl + { + public static string IntToString(int value, int radix, int width, char paddingChar, int flags) + { + if (flags != 0) + { + throw new NotImplementedException("IntToString with non-zero flags is not supported"); + } + string valueString = ""; + + if (radix == 2 || radix == 8 || radix == 16) + { + int shiftRightAmount = 1; + if (radix == 8) + { + shiftRightAmount = 3; + } + else if (radix == 16) + { + shiftRightAmount = 4; + } + if (value < 0) + { + throw new NotImplementedException(); + } + while (value > 0) + { + valueString = (value % radix).ToString("X") + valueString; + value >>= shiftRightAmount; + } + } + else if (radix == 10) + { + valueString = value.ToString(); + } + else + { + throw new ArgumentException(nameof(radix)); + } + + if (width == -1) + { + return valueString; + } + + if (valueString.Length > width) + { + throw new NotImplementedException("IntToString Case not handled when value is longer than width"); + } + + int count = width - valueString.Length; + for (int i = 0; i < count; i++) + { + valueString = paddingChar + valueString; + } + return valueString; + } + } +} From b322e1eafa1cbbcc3e96e13a16fc7f14281bf94a Mon Sep 17 00:00:00 2001 From: Quajak Date: Mon, 7 Sep 2020 16:09:06 +0200 Subject: [PATCH 06/27] Added new issue templates Proposed new issue template --- .github/ISSUE_TEMPLATE/bug_report.md | 22 ++++++++++++++ .../build-error-and-visual-studio-problems.md | 29 +++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 22 ++++++++++++++ .github/ISSUE_TEMPLATE/installation-error.md | 28 ++++++++++++++++++ .../ISSUE_TEMPLATE/installation-problem.md | 28 ++++++++++++++++++ .github/ISSUE_TEMPLATE/plug-request.md | 20 +++++++++++++ 6 files changed, 149 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/build-error-and-visual-studio-problems.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/installation-error.md create mode 100644 .github/ISSUE_TEMPLATE/installation-problem.md create mode 100644 .github/ISSUE_TEMPLATE/plug-request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..aa359040c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,22 @@ +--- +name: Bug report +about: For bugs in Cosmos +title: '' +labels: Bug +assignees: '' + +--- + +#### Area of Cosmos - What area of Cosmos are we dealing with? + + +#### Expected Behaviour - What do you think that should happen? + + +#### Actual Behaviour - What unexpectedly happens? + + +#### Reproduction - How did you get this error to appear? + + +#### Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)? diff --git a/.github/ISSUE_TEMPLATE/build-error-and-visual-studio-problems.md b/.github/ISSUE_TEMPLATE/build-error-and-visual-studio-problems.md new file mode 100644 index 000000000..8125653cb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/build-error-and-visual-studio-problems.md @@ -0,0 +1,29 @@ +--- +name: Build Error and Visual Studio Problems +about: For errors when trying to build a Cosmos Kernel or use VS +title: '' +labels: '' +assignees: '' + +--- + +Have you checked Github Issues for similar errors? + +**Exception** +Post the exception returned by Visual Studio + +** VS Output Logs ** +Post the entire output log given by Visual Studio for the build + +**To Reproduce** +Describe any changes done to a clean kernel for this error to occur. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Context** +Before posting please confirm that the following are in order +[ ] Both Cosmos VS Extensions are installed +[ ] The Cosmos nuget packages are installed + +Add any other context about the problem which might be helpful. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..5c6c65b4d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,22 @@ +--- +name: Feature request +about: Suggest an idea for Cosmos +title: '' +labels: Question +assignees: '' + +--- + +Have you checked for similar suggestions? + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/installation-error.md b/.github/ISSUE_TEMPLATE/installation-error.md new file mode 100644 index 000000000..a88743776 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/installation-error.md @@ -0,0 +1,28 @@ +--- +name: Installation Error +about: For errors while trying to install Cosmos +title: '' +labels: 'Area: Installer' +assignees: '' + +--- + +**Describe the problem** +A clear and concise description of where the installation is going wrong. + +**Steps of installation up to now** +Steps to reproduce the behavior: + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Logs** +Please post the entire log given by Cosmos. For long logs please use pastebin. + +**Steup (please complete the following information):** + - Cosmos Version (Userkit/Devkit) + - Are you using an admin account? + - VS Version if applicable + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/installation-problem.md b/.github/ISSUE_TEMPLATE/installation-problem.md new file mode 100644 index 000000000..10e737726 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/installation-problem.md @@ -0,0 +1,28 @@ +--- +name: Installation Problem +about: Create a report to help us improve +title: '' +labels: 'Area: Installer' +assignees: '' + +--- + +**Describe the problem** +A clear and concise description of where the installation is going wrong. + +**Steps of installation up to now** +Steps to reproduce the behavior: + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Logs** +Please post the entire log given by Cosmos. For long logs please use pastebin. + +**Steup (please complete the following information):** + - Cosmos Version (Userkit/Devkit) + - Are you using an admin account? + - VS Version if applicable + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/plug-request.md b/.github/ISSUE_TEMPLATE/plug-request.md new file mode 100644 index 000000000..f073317d1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/plug-request.md @@ -0,0 +1,20 @@ +--- +name: Plug request +about: Suggest that a certain method should be plugged +title: '' +labels: '' +assignees: '' + +--- + +**What is the usecase for this plug** +A clear and concise description of where the plug is needed + +** Complexity of plug ** +Can this plug be added without requiring new drivers or a lot of work? (Methods requiring Linq, Reflection or Networking etc. are too complex for this request) + +**Describe alternatives you've considered** +Are there ways to work around this plug not existing? + +**Additional context** +Add any other context about the plug request here. From 9d59f91e40de2fdb776592b8653487a69635061b Mon Sep 17 00:00:00 2001 From: Quajak Date: Mon, 7 Sep 2020 20:36:52 +0200 Subject: [PATCH 07/27] Fixed typo and reworded a few points --- .github/ISSUE_TEMPLATE/installation-problem.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/installation-problem.md b/.github/ISSUE_TEMPLATE/installation-problem.md index 10e737726..daceee95c 100644 --- a/.github/ISSUE_TEMPLATE/installation-problem.md +++ b/.github/ISSUE_TEMPLATE/installation-problem.md @@ -8,10 +8,10 @@ assignees: '' --- **Describe the problem** -A clear and concise description of where the installation is going wrong. +A clear and concise description of where the installation is going wrong/what error messages you got. **Steps of installation up to now** -Steps to reproduce the behavior: +What steps of the installation have you done up to now: **Expected behavior** A clear and concise description of what you expected to happen. @@ -19,7 +19,7 @@ A clear and concise description of what you expected to happen. **Logs** Please post the entire log given by Cosmos. For long logs please use pastebin. -**Steup (please complete the following information):** +**Setup (please complete the following information):** - Cosmos Version (Userkit/Devkit) - Are you using an admin account? - VS Version if applicable From e1bda335ab68db0b64f82e903fc77a4f86a06ce5 Mon Sep 17 00:00:00 2001 From: Quajak Date: Sat, 19 Sep 2020 21:44:28 +0200 Subject: [PATCH 08/27] Fix deleting of directories with small offset (most commonly subdirectories) --- .../System.IO/DirectoryTest.cs | 23 ++++++++----------- .../FAT/Listing/FatDiretoryEntry.cs | 23 +++++++++++++++---- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/Tests/Kernels/Cosmos.Kernel.Tests.Fat/System.IO/DirectoryTest.cs b/Tests/Kernels/Cosmos.Kernel.Tests.Fat/System.IO/DirectoryTest.cs index c77b509b5..465dbb173 100644 --- a/Tests/Kernels/Cosmos.Kernel.Tests.Fat/System.IO/DirectoryTest.cs +++ b/Tests/Kernels/Cosmos.Kernel.Tests.Fat/System.IO/DirectoryTest.cs @@ -12,7 +12,6 @@ namespace Cosmos.Kernel.Tests.Fat.System.IO /// public static void Execute(Debugger mDebugger) { - mDebugger.Send("START TEST: Delete a directory:"); Directory.CreateDirectory(@"0:\TestDir1"); Assert.IsTrue(Directory.Exists(@"0:\TestDir1"), "TestDir1 wasn't created!"); @@ -97,22 +96,20 @@ namespace Cosmos.Kernel.Tests.Fat.System.IO mDebugger.Send(""); -#if false - mDebugger.Send("START TEST: Delete a file with Directory.Delete:"); - File.Create(@"0:\file1.txt"); + mDebugger.Send("START TEST: Creating a subdirecty with Directory.CreateDirectory:"); - try - { - Directory.Delete(@"0:\file1.txt"); - } - catch (Exception e) - { - Assert.IsTrue(File.Exists(@"0:\file1.txt"), "The file was deleted by Directory.Delete."); - } + Directory.CreateDirectory(@"0:\TestDir1"); + Assert.IsTrue(Directory.Exists(@"0:\TestDir1"), "TestDir1 was created!"); + Directory.CreateDirectory(@"0:\TestDir1\test"); + Assert.IsTrue(Directory.Exists(@"0:\TestDir1\test"), "test subdirectory was created!"); + Directory.Delete(@"0:\TestDir1\test"); + Assert.IsFalse(Directory.Exists(@"0:\TestDir1\test"), "test subdirectory was deleted!"); + Directory.Delete(@"0:\TestDir1"); + Assert.IsFalse(Directory.Exists(@"0:\TestDir1"), "TestDir1 was deleted!"); mDebugger.Send("END TEST"); mDebugger.Send(""); -#endif + mDebugger.Send("START TEST: Create a directory with a Long Filename:"); Directory.CreateDirectory(@"0:\TestDir1"); diff --git a/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs b/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs index 55c1da0fc..c66dcb93d 100644 --- a/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs +++ b/source/Cosmos.System2/FileSystem/FAT/Listing/FatDiretoryEntry.cs @@ -512,6 +512,8 @@ namespace Cosmos.System.FileSystem.FAT.Listing /// Thrown when FAT type is unknown. public void DeleteDirectoryEntry() { + Global.mFileSystemDebugger.SendInternal("-- FatDirectoryEntry.DeleteDirectoryEntry --"); + if (mEntryType == DirectoryEntryTypeEnum.Unknown) { throw new NotImplementedException(); @@ -524,12 +526,17 @@ namespace Cosmos.System.FileSystem.FAT.Listing var xData = ((FatDirectoryEntry)mParent).GetDirectoryEntryData(); - var xEntryOffset = mEntryHeaderDataOffset - 32; - - while (xData[xEntryOffset + 11] == FatDirectoryEntryAttributeConsts.LongName) + if(mEntryHeaderDataOffset > 32) { - xData[xEntryOffset] = FatDirectoryEntryAttributeConsts.UnusedOrDeletedEntry; - xEntryOffset -= 32; + var xEntryOffset = mEntryHeaderDataOffset - 32; + + Global.mFileSystemDebugger.SendInternal("xEntryOffset: " + xEntryOffset); + + while (xData[xEntryOffset + 11] == FatDirectoryEntryAttributeConsts.LongName) + { + xData[xEntryOffset] = FatDirectoryEntryAttributeConsts.UnusedOrDeletedEntry; + xEntryOffset -= 32; + } } ((FatDirectoryEntry)mParent).SetDirectoryEntryData(xData); @@ -988,6 +995,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata aEntryMetadata, byte aValue) { Global.mFileSystemDebugger.SendInternal(" -- FatDirectoryEntry.SetDirectoryEntryMetadataValue(uint) --"); + Global.mFileSystemDebugger.SendInternal("aEntryMetadata = " + aEntryMetadata.DataOffset); Global.mFileSystemDebugger.SendInternal("aValue = " + aValue); if (IsRootDirectory()) @@ -1043,6 +1051,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata aEntryMetadata, ushort aValue) { Global.mFileSystemDebugger.SendInternal(" -- FatDirectoryEntry.SetDirectoryEntryMetadataValue(uint) --"); + Global.mFileSystemDebugger.SendInternal("aEntryMetadata = " + aEntryMetadata.DataOffset); Global.mFileSystemDebugger.SendInternal("aValue = " + aValue); if (IsRootDirectory()) @@ -1054,6 +1063,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing if (xData.Length > 0) { + Global.mFileSystemDebugger.SendInternal("mEntryHeaderDataOffset = " + mEntryHeaderDataOffset); var xValue = new byte[aEntryMetadata.DataLength]; xValue.SetUInt16(0, aValue); uint offset = mEntryHeaderDataOffset + aEntryMetadata.DataOffset; @@ -1100,6 +1110,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata aEntryMetadata, uint aValue) { Global.mFileSystemDebugger.SendInternal(" -- FatDirectoryEntry.SetDirectoryEntryMetadataValue(uint) --"); + Global.mFileSystemDebugger.SendInternal("aEntryMetadata = " + aEntryMetadata.DataOffset); Global.mFileSystemDebugger.SendInternal("aValue = " + aValue); if (IsRootDirectory()) @@ -1157,6 +1168,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata aEntryMetadata, long aValue) { Global.mFileSystemDebugger.SendInternal("-- FatDirectoryEntry.SetDirectoryEntryMetadataValue(long) --"); + Global.mFileSystemDebugger.SendInternal("aEntryMetadata = " + aEntryMetadata.DataOffset); Global.mFileSystemDebugger.SendInternal("aValue ="); Global.mFileSystemDebugger.SendInternal(aValue); @@ -1218,6 +1230,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata aEntryMetadata, string aValue) { Global.mFileSystemDebugger.SendInternal("-- FatDirectoryEntry.SetDirectoryEntryMetadataValue(string) --"); + Global.mFileSystemDebugger.SendInternal("aEntryMetadata = " + aEntryMetadata.DataOffset); Global.mFileSystemDebugger.SendInternal($"aValue = {aValue}"); if (IsRootDirectory()) From 0d426695acd1d7bce3d60ccae7a980aa1f2e7988 Mon Sep 17 00:00:00 2001 From: Quajak Date: Sun, 20 Sep 2020 17:41:35 +0200 Subject: [PATCH 09/27] Added plug for Multiboot.GetMBIAddress() --- Tests/Kernels/ProcessorTests/Kernel.cs | 6 ++++++ source/Cosmos.Core_Asm/MultibootImpl.cs | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Tests/Kernels/ProcessorTests/Kernel.cs b/Tests/Kernels/ProcessorTests/Kernel.cs index 93f9588cc..a4e195ff5 100644 --- a/Tests/Kernels/ProcessorTests/Kernel.cs +++ b/Tests/Kernels/ProcessorTests/Kernel.cs @@ -25,6 +25,7 @@ namespace ProcessorTests TestVendorNameIsNotBlank(); TestCycleCount(); TestCycleRateIsNotZero(); + TestMultiboot(); TestController.Completed(); } @@ -36,6 +37,11 @@ namespace ProcessorTests } } + public void TestMultiboot() + { + Assert.IsTrue(Multiboot.GetMBIAddress() != 0, $"Multiboot.GetMBIAddress works {Multiboot.GetMBIAddress()}"); + } + public void TestVendorNameIsNotBlank() { string vendorName = CPU.GetCPUVendorName(); diff --git a/source/Cosmos.Core_Asm/MultibootImpl.cs b/source/Cosmos.Core_Asm/MultibootImpl.cs index d3c9226ac..c2203981f 100644 --- a/source/Cosmos.Core_Asm/MultibootImpl.cs +++ b/source/Cosmos.Core_Asm/MultibootImpl.cs @@ -1,12 +1,25 @@ using Cosmos.Core; using IL2CPU.API.Attribs; +using XSharp; +using XSharp.Assembler; namespace Cosmos.Core_Asm { [Plug(Target = typeof(Multiboot))] public class MultibootImpl { - [PlugMethod(Assembler = typeof(MultibootAsm))] - public static uint GetMBIAddress() => throw null; + [PlugMethod(Assembler = typeof(MultibootImplAsm))] + public static uint GetMBIAddress() + { + return 0; + } + } + + public class MultibootImplAsm : AssemblerMethod + { + public override void AssembleNew(Assembler aAssembler, object aMethodInfo) + { + XS.Push("MultibootSignature"); + } } } From a4d0befbe1cb86052ae11cd3a1a4205b45169df2 Mon Sep 17 00:00:00 2001 From: Quajak Date: Sun, 27 Sep 2020 15:22:14 +0200 Subject: [PATCH 10/27] Made ReadCPUID public Made `ReadCPUID` and `CanReadCPUID` public. --- source/Cosmos.Core/CPU.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Cosmos.Core/CPU.cs b/source/Cosmos.Core/CPU.cs index cda877076..28c849a94 100644 --- a/source/Cosmos.Core/CPU.cs +++ b/source/Cosmos.Core/CPU.cs @@ -252,7 +252,7 @@ namespace Cosmos.Core /// /// non-zero if can read. /// Thrown on fatal error, contact support. - internal static int CanReadCPUID() => throw new NotImplementedException(); + public static int CanReadCPUID() => throw new NotImplementedException(); /// /// Read CPU ID. Plugged. @@ -263,7 +263,7 @@ namespace Cosmos.Core /// ecx. /// edx. /// Thrown on fatal error, contact support. - internal static void ReadCPUID(uint type, ref int eax, ref int ebx, ref int ecx, ref int edx) => throw new NotImplementedException(); + public static void ReadCPUID(uint type, ref int eax, ref int ebx, ref int ecx, ref int edx) => throw new NotImplementedException(); /// /// Read timestamp counter. Plugged. From 980e06453eba12ccd0eb8cecef00ae1848c29a56 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Mon, 28 Sep 2020 12:19:14 -0500 Subject: [PATCH 11/27] Remove ProcessorInformation Closes #1487 --- source/Cosmos.Core/ProcessorInformation.cs | 64 ------ .../ProcessorInformationImpl.cs | 212 ------------------ .../System/Diagnostics/StopwatchImpl.cs | 2 +- .../System/Threading/ThreadImpl.cs | 6 +- 4 files changed, 4 insertions(+), 280 deletions(-) delete mode 100644 source/Cosmos.Core/ProcessorInformation.cs delete mode 100644 source/Cosmos.Core_Asm/ProcessorInformationImpl.cs diff --git a/source/Cosmos.Core/ProcessorInformation.cs b/source/Cosmos.Core/ProcessorInformation.cs deleted file mode 100644 index 68c2be024..000000000 --- a/source/Cosmos.Core/ProcessorInformation.cs +++ /dev/null @@ -1,64 +0,0 @@ -namespace Cosmos.Core -{ - /// - /// ProcessorInformation class. Used to get vendor information from the CPU. - /// - public unsafe class ProcessorInformation - { - /// - /// Returns the Processor's vendor name - /// - /// CPU Vendor name - public static string GetVendorName() - { - if (CanReadCPUID() > 0) - { - int[] raw = new int[3]; - - fixed (int* ptr = raw) - FetchCPUVendor(ptr); - - return new string(new char[] { - (char)(raw[0] >> 24), - (char)((raw[0] >> 16) & 0xff), - (char)((raw[0] >> 8) & 0xff), - (char)(raw[0] & 0xff), - (char)(raw[1] >> 24), - (char)((raw[1] >> 16) & 0xff), - (char)((raw[1] >> 8) & 0xff), - (char)(raw[1] & 0xff), - (char)(raw[2] >> 24), - (char)((raw[2] >> 16) & 0xff), - (char)((raw[2] >> 8) & 0xff), - (char)(raw[2] & 0xff), - }); - } - else - return "\0"; - } - - /// - /// Check if can read CPU ID. - /// - /// int value. - internal static int CanReadCPUID() => 0; //plugged - - /// - /// Fetch CPU vendor. - /// - /// pointer to target. - internal static void FetchCPUVendor(int* target) { } //plugged - - /// - /// Returns the number of CPU cycles since startup of the current CPU core - /// - /// Number of CPU cycles since startup - public static long GetCycleCount() => 0; //plugged - - /// - /// Returns the number of CPU cycles per seconds - /// - /// Number of CPU cycles per seconds - public static long GetCycleRate() => 0; //plugged - } -} diff --git a/source/Cosmos.Core_Asm/ProcessorInformationImpl.cs b/source/Cosmos.Core_Asm/ProcessorInformationImpl.cs deleted file mode 100644 index 2bd7d4c4a..000000000 --- a/source/Cosmos.Core_Asm/ProcessorInformationImpl.cs +++ /dev/null @@ -1,212 +0,0 @@ -using Cosmos.Core; - -using IL2CPU.API; -using IL2CPU.API.Attribs; - -using XSharp; - -namespace Cosmos.Core_Asm -{ - [Plug(Target = typeof(ProcessorInformation))] - public unsafe class ProcessorInformationImpl - { - /* The following three int*-pointers are needed for the lea instruction due to the following reason: - * When comiling, the IL-code will be translated into x86-ASM, which has specific and unique names for local variables. - * To access these local variables, I have to pass their excat name to the instruction in question. This is rather - * difficult with reflection, if these variables reside in the local function scope. For this reason, I move the - * pointer to class scope to access them quicker and more easily - */ - private static int* __cyclesrdtscptr, __raterdmsrptr, __vendortargetptr; - private static long __ticktate = -1; - - /// - /// Returns the number of CPU cycles since startup - /// - /// Number of CPU cycles - public static long GetCycleCount() - { - int[] val = new int[2]; - - fixed (int* ptr = val) - { - __cyclesrdtsc(ptr); - } - - return ((long)val[0] << 32) | (uint)val[1]; - } - - /// - /// Returns the CPU cycle rate (in cycles/µs) - /// - /// CPU cycle rate - public static long GetCycleRate() - { - if (__ticktate == -1) - { - int[] raw = new int[4]; - - fixed (int* ptr = raw) - { - __raterdmsr(ptr); - } - - ulong l1 = (ulong)__maxrate(); - ulong l2 = ((ulong)raw[0] << 32) | (uint)raw[1]; - ulong l3 = ((ulong)raw[2] << 32) | (uint)raw[3]; - - __ticktate = (long)l2; // (long)((double)l1 * l3 / l2); - } - - return __ticktate; - } - - /// - /// Copies the maximum cpu rate set by the bios at startup to the given int pointer - /// - [Inline] - private static int __maxrate() - { - /* - * mov eax, 16h - * cpuid - * and eax, ffffh - * ret - */ - - XS.Set(XSRegisters.EAX, 0x00000016); - XS.Cpuid(); - XS.And(XSRegisters.EAX, 0x0000ffff); - XS.Return(); - - return 0; - } - - /// - /// Copies the cycle count to the given int pointer - /// - [Inline] - private static void __cyclesrdtsc(int* target) - { - /* - * push eax - * push ecx - * push edx - * lea esi, target - * rdtsc - * mov [esi+4], eax - * mov [esi], edx - * pop edx - * pop ecx - * pop eax - * ret - */ - __cyclesrdtscptr = target; - - string intname = LabelName.GetStaticFieldName(typeof(CPUImpl).GetField(nameof(__cyclesrdtscptr))); - - XS.Push(XSRegisters.EAX); - XS.Push(XSRegisters.ECX); - XS.Push(XSRegisters.EDX); - XS.Lea(XSRegisters.ESI, intname); - XS.Rdtsc(); - XS.Set(XSRegisters.ESI, XSRegisters.EAX, destinationIsIndirect: true, destinationDisplacement: 4); - XS.Set(XSRegisters.ESI, XSRegisters.EDX, destinationIsIndirect: true); - XS.Push(XSRegisters.EDX); - XS.Push(XSRegisters.ECX); - XS.Push(XSRegisters.EAX); - XS.Return(); - } - - /// - /// Copies the cycle rate to the given int pointer - /// - [Inline] - private static void __raterdmsr(int* target) - { - /* - * ; esi register layout: (mperf_hi, mperf_lo, aperf_hi, aperf_lo) - * ; - * ; int* ptr = new int[4]; - * ; - * lea esi, ptr ;equivalent with `mov esi, &ptr` - * mov ecx, e7h - * rdmsr - * mov [esi + 4], eax - * mov [esi], edx - * mov ecx, e8h - * rdmsr - * mov [esi + 12], eax - * mov [esi + 8], edx - * xor eax, eax - * ret - */ - __raterdmsrptr = target; - - string intname = LabelName.GetStaticFieldName(typeof(CPUImpl).GetField(nameof(__raterdmsrptr))); - - XS.Lea(XSRegisters.ESI, intname); - XS.Set(XSRegisters.ECX, 0xe7); - XS.Rdmsr(); - XS.Set(XSRegisters.EAX, XSRegisters.ESI, destinationIsIndirect: true, destinationDisplacement: 4); - XS.Set(XSRegisters.EDX, XSRegisters.ESI, destinationIsIndirect: true, destinationDisplacement: 0); - XS.Set(XSRegisters.ECX, 0xe8); - XS.Rdmsr(); - XS.Set(XSRegisters.EAX, XSRegisters.ESI, destinationIsIndirect: true, destinationDisplacement: 12); - XS.Set(XSRegisters.EDX, XSRegisters.ESI, destinationIsIndirect: true, destinationDisplacement: 8); - XS.Xor(XSRegisters.EAX, XSRegisters.EAX); // XS.Set(XSRegisters.EAX, 0); - XS.Return(); - } - - [Inline] - internal static void FetchCPUVendor(int* target) - { - /* - * lea esi, target - * xor eax, eax - * cpuid - * mov [esi], ebx - * mov [esi + 4], edx - * mov [esi + 8], ecx - * ret - */ - __vendortargetptr = target; - - string intname = LabelName.GetStaticFieldName(typeof(CPUImpl).GetField(nameof(__vendortargetptr))); - - XS.Lea(XSRegisters.ESI, intname); // new Lea { DestinationReg = RegistersEnum.ESI, SourceRef = ElementReference.New(intname) }; - XS.Cpuid(); - XS.Set(XSRegisters.ESI, XSRegisters.EBX, destinationIsIndirect: true); - XS.Set(XSRegisters.ESI, XSRegisters.EDX, destinationIsIndirect: true, destinationDisplacement: 4); - XS.Set(XSRegisters.ESI, XSRegisters.ECX, destinationIsIndirect: true, destinationDisplacement: 8); - XS.Return(); - } - - [Inline] - internal static int CanReadCPUID() - { - /* - * pushfd - * pushfd - * xor dword [esp], 00200000h - * popfd - * pushfd - * pop eax - * xor eax, [esp] - * and eax, 00200000h - * ret - */ - XS.Pushfd(); - XS.Pushfd(); - XS.Xor(XSRegisters.ESP, 0x00200000, destinationIsIndirect: true); - XS.Popfd(); - XS.Pushfd(); - XS.Pop(XSRegisters.EAX); - XS.Xor(XSRegisters.EAX, XSRegisters.ESP, destinationIsIndirect: true); - XS.Popfd(); - XS.And(XSRegisters.EAX, 0x00200000); - XS.Return(); - - return 0; // should be ignored by the compiler - } - } -} diff --git a/source/Cosmos.Core_Plugs/System/Diagnostics/StopwatchImpl.cs b/source/Cosmos.Core_Plugs/System/Diagnostics/StopwatchImpl.cs index c2f117ac2..19f86361b 100644 --- a/source/Cosmos.Core_Plugs/System/Diagnostics/StopwatchImpl.cs +++ b/source/Cosmos.Core_Plugs/System/Diagnostics/StopwatchImpl.cs @@ -13,7 +13,7 @@ namespace Cosmos.Core_Plugs.System.Diagnostics { if (Stopwatch.IsHighResolution) // see https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx for more details - return (long)(ProcessorInformation.GetCycleCount() / (double)ProcessorInformation.GetCycleRate() * 1000000d); + return (long)(CPU.GetCPUUptime() / (double)CPU.GetCPUUptime() * 1000000d); else return DateTime.UtcNow.Ticks; } diff --git a/source/Cosmos.Core_Plugs/System/Threading/ThreadImpl.cs b/source/Cosmos.Core_Plugs/System/Threading/ThreadImpl.cs index 383dd9505..9c28ca3ef 100644 --- a/source/Cosmos.Core_Plugs/System/Threading/ThreadImpl.cs +++ b/source/Cosmos.Core_Plugs/System/Threading/ThreadImpl.cs @@ -23,10 +23,10 @@ namespace Cosmos.Core_Plugs.System.Threading // if ((ms > 0) && (ms != Timeout.Infinite)) // { - // double fac = ProcessorInformation.GetCycleRate() / 1000d; - // double ticks = ms / 1000d * Stopwatch.Frequency + ProcessorInformation.GetCycleCount() * fac; + // double fac = CPU.GetCycleRate() / 1000d; + // double ticks = ms / 1000d * Stopwatch.Frequency + CPU.GetCycleCount() * fac; - // while (ticks < ProcessorInformation.GetCycleCount() * fac) + // while (ticks < CPU.GetCycleCount() * fac) // new Action(() => { }).Invoke(); // execute an empty operation // } // else if (ms < 0) From 6ac875c1943935274391706628183a7500256fb8 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Wed, 7 Oct 2020 22:09:28 -0500 Subject: [PATCH 12/27] Switch back to bachs as default --- Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs b/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs index 22958fb1e..7946c6206 100644 --- a/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs +++ b/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs @@ -14,10 +14,10 @@ namespace Cosmos.TestRunner.Full { get { - //yield return RunTargetEnum.Bochs; + yield return RunTargetEnum.Bochs; //yield return RunTargetEnum.VMware; //yield return RunTargetEnum.HyperV; - yield return RunTargetEnum.Qemu; + //yield return RunTargetEnum.Qemu; } } From 93e32b02046cf86c6745a1fcd6d512079dce33b2 Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Fri, 16 Oct 2020 23:04:42 +0200 Subject: [PATCH 13/27] [WiP] Color.FromName Plug --- .../System/Drawing/ColorImpl.cs | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs diff --git a/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs b/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs new file mode 100644 index 000000000..d1ea660f4 --- /dev/null +++ b/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs @@ -0,0 +1,184 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using IL2CPU.API.Attribs; + +namespace Cosmos.System_Plugs.System.Drawing +{ + [Plug(Target = typeof(global::System.Drawing.Color))] + class ColorImpl + { + public static Color FromName(string name) + { + switch(name) + { + case "AliceBlue": + return Color.AliceBlue; + break; + case "AntiqueWhite": + return Color.AntiqueWhite; + break; + case "Aqua": + return Color.Aqua; + break; + case "Aquamarine": + return Color.Aquamarine; + break; + case "Azure": + return Color.Azure; + break; + case "Beige": + return Color.Beige; + break; + case "Bisque": + return Color.Bisque; + break; + case "Black": + return Color.Black; + break; + case "BlueViolet": + return Color.BlueViolet; + break; + case "Brown": + return Color.Brown; + break; + case "BurlyWood": + return Color.BurlyWood; + break; + case "CadetBlue": + return Color.CadetBlue; + break; + case "Chartreuse": + return Color.Chartreuse; + break; + case "Chocolate": + return Color.Chocolate; + break; + case "Coral": + return Color.Coral; + break; + case "CornflowerBlue": + return Color.CornflowerBlue; + break; + case "Cornsilk": + return Color.Cornsilk; + break; + case "Crimson": + return Color.Crimson; + break; + case "Cyan": + return Color.Cyan; + break; + case "DarkBlue": + return Color.DarkBlue; + break; + case "DarkCyan": + return Color.DarkCyan; + break; + case "DarkGoldenrod": + return Color.DarkGoldenrod; + break; + case "DarkGray": + return Color.DarkGray; + break; + case "DarkGreen": + return Color.DarkGreen; + break; + case "DarkKhaki": + return Color.DarkKhaki; + break; + case "DarkMagenta": + return Color.DarkMagenta; + break; + case "DarkOliveGreen": + return Color.DarkOliveGreen; + break; + case "AliceOrange": + return Color.DarkOrange; + break; + case "DarkOrchid": + return Color.DarkOrchid; + break; + case "DarkRed": + return Color.DarkRed; + break; + case "DarkSalmon": + return Color.DarkSalmon; + break; + case "DarkSeaGreen": + return Color.DarkSeaGreen; + break; + case "DarkSlateBlue": + return Color.DarkSlateBlue; + break; + case "DarkSlateGray": + return Color.DarkSlateGray; + break; + case "DarkTurquoise": + return Color.DarkTurquoise; + break; + case "DarkViolet": + return Color.DarkViolet; + break; + case "DeepPink": + return Color.DeepPink; + break; + case "DeepSkyBlue": + return Color.DeepSkyBlue; + break; + case "DimGray": + return Color.DimGray; + break; + case "DodgerBlue": + return Color.DodgerBlue; + break; + case "Firebrick": + return Color.Firebrick; + break; + case "FloralWhite": + return Color.FloralWhite; + break; + case "ForestGreen": + return Color.ForestGreen; + break; + case "Fuchsia": + return Color.Fuchsia; + break; + case "Gainsboro": + return Color.Gainsboro; + break; + case "GhostWhite": + return Color.GhostWhite; + break; + case "Gold": + return Color.Gold; + break; + case "Goldenrod": + return Color.Goldenrod; + break; + case "Gray": + return Color.Gray; + break; + case "Green": + return Color.Green; + break; + case "GreenYellow": + return Color.GreenYellow; + break; + case "Honeydew": + return Color.Honeydew; + break; + case "HotPink": + return Color.HotPink; + break; + case "": + throw new Exception("Color Name must be passed to FromName"); + break; + default: + return Color.Black; + break; + } + } + } +} From f783dace2e10d0a067a9486b4db99ef11dc2815d Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Sat, 17 Oct 2020 20:28:43 +0200 Subject: [PATCH 14/27] Update ColorImpl.cs Change Exception to ArgumentException --- source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs b/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs index d1ea660f4..319019234 100644 --- a/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs +++ b/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs @@ -173,7 +173,7 @@ namespace Cosmos.System_Plugs.System.Drawing return Color.HotPink; break; case "": - throw new Exception("Color Name must be passed to FromName"); + throw new ArgumentException("Color Name must be passed to FromName"); break; default: return Color.Black; From 7fd9abf515d1825c8fa03a61881cb6a84da72fd9 Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Sun, 18 Oct 2020 13:18:07 +0200 Subject: [PATCH 15/27] Finish Plug Add Remainig Colors, also throw a exception on Invalid Color Name instead or returning Black --- .../System/Drawing/ColorImpl.cs | 258 +++++++++++++++++- 1 file changed, 257 insertions(+), 1 deletion(-) diff --git a/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs b/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs index 319019234..8e88577ac 100644 --- a/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs +++ b/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs @@ -1,3 +1,4 @@ +//#define COSMOSDEBUG using System; using System.Collections.Generic; using System.Drawing; @@ -9,6 +10,9 @@ namespace Cosmos.System_Plugs.System.Drawing [Plug(Target = typeof(global::System.Drawing.Color))] class ColorImpl { + /// Implements System.Drawing.Color.FromName + /// See https://docs.microsoft.com/de-de/dotnet/api/system.drawing.color.fromname?view=netcore-3.1 for Usage Explanation + /// public static Color FromName(string name) { switch(name) @@ -172,11 +176,263 @@ namespace Cosmos.System_Plugs.System.Drawing case "HotPink": return Color.HotPink; break; + case "IndianRed": + return Color.IndianRed; + break; + case "Indigo": + return Color.Indigo; + break; + case "Ivory": + return Color.Ivory; + break; + case "Khaki": + return Color.Khaki; + break; + case "Lavender": + return Color.Lavender; + break; + case "LavenderBlush": + return Color.LavenderBlush; + break; + case "LawnGreen": + return Color.LawnGreen; + break; + case "LemonChiffon": + return Color.LemonChiffon; + break; + case "LightBlue": + return Color.LightBlue; + break; + case "LightCoral": + return Color.LightCoral; + break; + case "LightCyan": + return Color.LightCyan; + break; + case "LightGoldenrodYellow": + return Color.LightGoldenrodYellow; + break; + case "LightGreen": + return Color.LightGreen; + break; + case "LightGray": + return Color.LightGray; + break; + case "LightPink": + return Color.LightPink; + break; + case "LightSalmon": + return Color.LightSalmon; + break; + case "LightSeaGreen": + return Color.LightSeaGreen; + break; + case "LightSkyBlue": + return Color.LightSkyBlue; + break; + case "LightSlateGray": + return Color.LightSlateGray; + break; + case "LightSteelBlue": + return Color.LightSteelBlue; + break; + case "LightYellow": + return Color.LightYellow; + break; + case "Lime": + return Color.Lime; + break; + case "LimeGreen": + return Color.LimeGreen; + break; + case "Linen": + return Color.Linen; + break; + case "Magenta": + return Color.Magenta; + break; + case "Maroon": + return Color.Maroon; + break; + case "MediumAquamarine": + return Color.MediumAquamarine ; + break; + case "MediumBlue": + return Color.MediumBlue; + break; + case "MediumOrchid": + return Color.MediumOrchid; + break; + case "MediumPurple": + return Color.MediumPurple; + break; + case "MediumSeaGreen": + return Color.MediumSeaGreen; + break; + case "MediumSlateBlue": + return Color.MediumSlateBlue; + break; + case "MediumSpringGreen": + return Color.MediumSpringGreen; + break; + case "MediumTurquoise": + return Color.MediumTurquoise; + break; + case "MediumVioletRed": + return Color.MediumVioletRed; + break; + case "MidnightBlue": + return Color.MidnightBlue; + break; + case "MintCream": + return Color.MintCream; + break; + case "MistyRose": + return Color.MistyRose; + break; + case "Moccasin": + return Color.Moccasin; + break; + case "NavajoWhite": + return Color.NavajoWhite; + break; + case "Navy": + return Color.Navy; + break; + case "OldLace": + return Color.OldLace; + break; + case "Olive": + return Color.Olive; + break; + case "OliveDrab": + return Color.OliveDrab; + break; + case "Orange": + return Color.Orange; + break; + case "OrangeRed": + return Color.OrangeRed; + break; + case "Orchid": + return Color.Orchid; + break; + case "PaleGoldenrod": + return Color.PaleGoldenrod; + break; + case "PaleGreen": + return Color.PaleGreen; + break; + case "PaleTurquoise": + return Color.PaleTurquoise; + break; + case "PaleVioletRed": + return Color.PaleVioletRed; + break; + case "PapayaWhip": + return Color.PapayaWhip; + break; + case "PeachPuff": + return Color.PeachPuff; + break; + case "Peru": + return Color.Peru; + break; + case "Pink": + return Color.Pink; + break; + case "Plum": + return Color.Plum; + break; + case "PowderBlue": + return Color.PowderBlue; + break; + case "Purple": + return Color.Purple; + break; + case "Red": + return Color.Red; + break; + case "RosyBrown": + return Color.RosyBrown; + break; + case "RoyalBlue": + return Color.RoyalBlue; + break; + case "SaddleBrown": + return Color.SaddleBrown; + break; + case "Salmon": + return Color.Salmon; + break; + case "SandyBrown": + return Color.SandyBrown; + break; + case "SeaGreen": + return Color.SeaGreen; + break; + case "Sienna": + return Color.Sienna; + break; + case "Silver": + return Color.Silver; + break; + case "SkyBlue": + return Color.SkyBlue; + break; + case "SlateBlue": + return Color.SlateBlue; + break; + case "SlateGray": + return Color.SlateGray; + break; + case "Snow": + return Color.Snow; + break; + case "SpringGreen": + return Color.SpringGreen; + break; + case "SteelBlue": + return Color.SteelBlue; + break; + case "Tan": + return Color.Tan; + break; + case "Thistle": + return Color.Thistle; + break; + case "Tomato": + return Color.Tomato; + break; + case "Transparent": + return Color.Transparent; + break; + case "Turquoise": + return Color.Turquoise; + break; + case "Violet": + return Color.Violet; + break; + case "Wheat": + return Color.Wheat; + break; + case "White": + return Color.White; + break; + case "WhiteSmoke": + return Color.WhiteSmoke; + break; + case "Yellow": + return Color.Yellow; + break; + case "YellowGreen": + return Color.YellowGreen; + break; case "": throw new ArgumentException("Color Name must be passed to FromName"); break; default: - return Color.Black; + throw new ArgumentException("{0} is not a valid Color Name", name); break; } } From 3a0c3884bb4690a8681b1a2afe85d1ec794d2176 Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Sun, 18 Oct 2020 16:23:09 +0200 Subject: [PATCH 16/27] Update ColorImpl.cs Remove break Statements since we have return values --- .../System/Drawing/ColorImpl.cs | 278 +++++++++--------- 1 file changed, 139 insertions(+), 139 deletions(-) diff --git a/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs b/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs index 8e88577ac..4a005b644 100644 --- a/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs +++ b/source/Cosmos.System2_Plugs/System/Drawing/ColorImpl.cs @@ -19,421 +19,421 @@ namespace Cosmos.System_Plugs.System.Drawing { case "AliceBlue": return Color.AliceBlue; - break; + case "AntiqueWhite": return Color.AntiqueWhite; - break; + case "Aqua": return Color.Aqua; - break; + case "Aquamarine": return Color.Aquamarine; - break; + case "Azure": return Color.Azure; - break; + case "Beige": return Color.Beige; - break; + case "Bisque": return Color.Bisque; - break; + case "Black": return Color.Black; - break; + case "BlueViolet": return Color.BlueViolet; - break; + case "Brown": return Color.Brown; - break; + case "BurlyWood": return Color.BurlyWood; - break; + case "CadetBlue": return Color.CadetBlue; - break; + case "Chartreuse": return Color.Chartreuse; - break; + case "Chocolate": return Color.Chocolate; - break; + case "Coral": return Color.Coral; - break; + case "CornflowerBlue": return Color.CornflowerBlue; - break; + case "Cornsilk": return Color.Cornsilk; - break; + case "Crimson": return Color.Crimson; - break; + case "Cyan": return Color.Cyan; - break; + case "DarkBlue": return Color.DarkBlue; - break; + case "DarkCyan": return Color.DarkCyan; - break; + case "DarkGoldenrod": return Color.DarkGoldenrod; - break; + case "DarkGray": return Color.DarkGray; - break; + case "DarkGreen": return Color.DarkGreen; - break; + case "DarkKhaki": return Color.DarkKhaki; - break; + case "DarkMagenta": return Color.DarkMagenta; - break; + case "DarkOliveGreen": return Color.DarkOliveGreen; - break; + case "AliceOrange": return Color.DarkOrange; - break; + case "DarkOrchid": return Color.DarkOrchid; - break; + case "DarkRed": return Color.DarkRed; - break; + case "DarkSalmon": return Color.DarkSalmon; - break; + case "DarkSeaGreen": return Color.DarkSeaGreen; - break; + case "DarkSlateBlue": return Color.DarkSlateBlue; - break; + case "DarkSlateGray": return Color.DarkSlateGray; - break; + case "DarkTurquoise": return Color.DarkTurquoise; - break; + case "DarkViolet": return Color.DarkViolet; - break; + case "DeepPink": return Color.DeepPink; - break; + case "DeepSkyBlue": return Color.DeepSkyBlue; - break; + case "DimGray": return Color.DimGray; - break; + case "DodgerBlue": return Color.DodgerBlue; - break; + case "Firebrick": return Color.Firebrick; - break; + case "FloralWhite": return Color.FloralWhite; - break; + case "ForestGreen": return Color.ForestGreen; - break; + case "Fuchsia": return Color.Fuchsia; - break; + case "Gainsboro": return Color.Gainsboro; - break; + case "GhostWhite": return Color.GhostWhite; - break; + case "Gold": return Color.Gold; - break; + case "Goldenrod": return Color.Goldenrod; - break; + case "Gray": return Color.Gray; - break; + case "Green": return Color.Green; - break; + case "GreenYellow": return Color.GreenYellow; - break; + case "Honeydew": return Color.Honeydew; - break; + case "HotPink": return Color.HotPink; - break; + case "IndianRed": return Color.IndianRed; - break; + case "Indigo": return Color.Indigo; - break; + case "Ivory": return Color.Ivory; - break; + case "Khaki": return Color.Khaki; - break; + case "Lavender": return Color.Lavender; - break; + case "LavenderBlush": return Color.LavenderBlush; - break; + case "LawnGreen": return Color.LawnGreen; - break; + case "LemonChiffon": return Color.LemonChiffon; - break; + case "LightBlue": return Color.LightBlue; - break; + case "LightCoral": return Color.LightCoral; - break; + case "LightCyan": return Color.LightCyan; - break; + case "LightGoldenrodYellow": return Color.LightGoldenrodYellow; - break; + case "LightGreen": return Color.LightGreen; - break; + case "LightGray": return Color.LightGray; - break; + case "LightPink": return Color.LightPink; - break; + case "LightSalmon": return Color.LightSalmon; - break; + case "LightSeaGreen": return Color.LightSeaGreen; - break; + case "LightSkyBlue": return Color.LightSkyBlue; - break; + case "LightSlateGray": return Color.LightSlateGray; - break; + case "LightSteelBlue": return Color.LightSteelBlue; - break; + case "LightYellow": return Color.LightYellow; - break; + case "Lime": return Color.Lime; - break; + case "LimeGreen": return Color.LimeGreen; - break; + case "Linen": return Color.Linen; - break; + case "Magenta": return Color.Magenta; - break; + case "Maroon": return Color.Maroon; - break; + case "MediumAquamarine": return Color.MediumAquamarine ; - break; + case "MediumBlue": return Color.MediumBlue; - break; + case "MediumOrchid": return Color.MediumOrchid; - break; + case "MediumPurple": return Color.MediumPurple; - break; + case "MediumSeaGreen": return Color.MediumSeaGreen; - break; + case "MediumSlateBlue": return Color.MediumSlateBlue; - break; + case "MediumSpringGreen": return Color.MediumSpringGreen; - break; + case "MediumTurquoise": return Color.MediumTurquoise; - break; + case "MediumVioletRed": return Color.MediumVioletRed; - break; + case "MidnightBlue": return Color.MidnightBlue; - break; + case "MintCream": return Color.MintCream; - break; + case "MistyRose": return Color.MistyRose; - break; + case "Moccasin": return Color.Moccasin; - break; + case "NavajoWhite": return Color.NavajoWhite; - break; + case "Navy": return Color.Navy; - break; + case "OldLace": return Color.OldLace; - break; + case "Olive": return Color.Olive; - break; + case "OliveDrab": return Color.OliveDrab; - break; + case "Orange": return Color.Orange; - break; + case "OrangeRed": return Color.OrangeRed; - break; + case "Orchid": return Color.Orchid; - break; + case "PaleGoldenrod": return Color.PaleGoldenrod; - break; + case "PaleGreen": return Color.PaleGreen; - break; + case "PaleTurquoise": return Color.PaleTurquoise; - break; + case "PaleVioletRed": return Color.PaleVioletRed; - break; + case "PapayaWhip": return Color.PapayaWhip; - break; + case "PeachPuff": return Color.PeachPuff; - break; + case "Peru": return Color.Peru; - break; + case "Pink": return Color.Pink; - break; + case "Plum": return Color.Plum; - break; + case "PowderBlue": return Color.PowderBlue; - break; + case "Purple": return Color.Purple; - break; + case "Red": return Color.Red; - break; + case "RosyBrown": return Color.RosyBrown; - break; + case "RoyalBlue": return Color.RoyalBlue; - break; + case "SaddleBrown": return Color.SaddleBrown; - break; + case "Salmon": return Color.Salmon; - break; + case "SandyBrown": return Color.SandyBrown; - break; + case "SeaGreen": return Color.SeaGreen; - break; + case "Sienna": return Color.Sienna; - break; + case "Silver": return Color.Silver; - break; + case "SkyBlue": return Color.SkyBlue; - break; + case "SlateBlue": return Color.SlateBlue; - break; + case "SlateGray": return Color.SlateGray; - break; + case "Snow": return Color.Snow; - break; + case "SpringGreen": return Color.SpringGreen; - break; + case "SteelBlue": return Color.SteelBlue; - break; + case "Tan": return Color.Tan; - break; + case "Thistle": return Color.Thistle; - break; + case "Tomato": return Color.Tomato; - break; + case "Transparent": return Color.Transparent; - break; + case "Turquoise": return Color.Turquoise; - break; + case "Violet": return Color.Violet; - break; + case "Wheat": return Color.Wheat; - break; + case "White": return Color.White; - break; + case "WhiteSmoke": return Color.WhiteSmoke; - break; + case "Yellow": return Color.Yellow; - break; + case "YellowGreen": return Color.YellowGreen; - break; + case "": throw new ArgumentException("Color Name must be passed to FromName"); - break; + default: throw new ArgumentException("{0} is not a valid Color Name", name); - break; + } } } From 784eb4477416684d0201a53147bd7083ab2ecb4d Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Sun, 18 Oct 2020 16:45:49 +0200 Subject: [PATCH 17/27] Update Kernel.cs Test Color.FromName --- Tests/Kernels/GraphicTest/Kernel.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/Kernels/GraphicTest/Kernel.cs b/Tests/Kernels/GraphicTest/Kernel.cs index 94ddbbe4e..d6a6a4351 100644 --- a/Tests/Kernels/GraphicTest/Kernel.cs +++ b/Tests/Kernels/GraphicTest/Kernel.cs @@ -83,6 +83,9 @@ namespace GraphicTest pen.Color = Color.MediumPurple; aCanvas.DrawPolygon(pen, new Point(200, 250), new Point(250, 300), new Point(220, 350), new Point(210, 275)); + /* Color.FromName */ + aCanvas.Clear(Color.FromName("Navy")); + /* A LimeGreen rectangle */ pen.Color = Color.LimeGreen; aCanvas.DrawRectangle(pen, 450, 300, 80, 60); From 3e3144a362c8db81a26e3a7bbd5d5646f827f3eb Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Sun, 18 Oct 2020 16:53:21 +0200 Subject: [PATCH 18/27] Fix Laptop Touchpads Tested this on 3 Different Laptops from different brands, all touchpads worked without any issues --- source/Cosmos.HAL2/PS2Controller.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/Cosmos.HAL2/PS2Controller.cs b/source/Cosmos.HAL2/PS2Controller.cs index 83584df81..ab450a56e 100644 --- a/source/Cosmos.HAL2/PS2Controller.cs +++ b/source/Cosmos.HAL2/PS2Controller.cs @@ -176,8 +176,10 @@ namespace Cosmos.HAL * |--------|---------------------------| * | 0x04 | 5-button mouse | * |--------|---------------------------| + * | 0x50 | Laptop Touchpad | + * |--------|---------------------------| */ - if (xFirstByte == 0x00 || xFirstByte == 0x03 || xFirstByte == 0x04) + if (xFirstByte == 0x00 || xFirstByte == 0x03 || xFirstByte == 0x04 || xFirstByte == 0x50) { var xDevice = new PS2Mouse(aPort, xFirstByte); xDevice.Initialize(); From 8996b1f8a303b2fb699a1b70153e77dbe207ec95 Mon Sep 17 00:00:00 2001 From: Quajak Date: Mon, 19 Oct 2020 00:35:42 +0200 Subject: [PATCH 19/27] Added CPU.GetMemoryMap Fixed GetMBIAddress Plug Cleaned up code --- Tests/Kernels/ProcessorTests/Kernel.cs | 18 ++++ source/Cosmos.Core/Bootstrap.cs | 16 ++-- source/Cosmos.Core/CPU.cs | 111 ++++++++++++++++++++++-- source/Cosmos.Core/MemoryOperations.cs | 33 ++++--- source/Cosmos.Core/Multiboot.cs | 2 +- source/Cosmos.Core_Asm/MultibootImpl.cs | 2 +- 6 files changed, 153 insertions(+), 29 deletions(-) diff --git a/Tests/Kernels/ProcessorTests/Kernel.cs b/Tests/Kernels/ProcessorTests/Kernel.cs index 2320625f3..74b2c79cb 100644 --- a/Tests/Kernels/ProcessorTests/Kernel.cs +++ b/Tests/Kernels/ProcessorTests/Kernel.cs @@ -22,6 +22,8 @@ namespace ProcessorTests { try { + TestMultibootMemoryMap(); + TetsGetRam(); TestVendorNameIsNotBlank(); TestCycleCount(); TestCycleRateIsNotZero(); @@ -37,6 +39,22 @@ namespace ProcessorTests } } + public void TetsGetRam() + { + Assert.IsTrue(CPU.GetAmountOfRAM() > 0, "CPU.GetAmountOfRAM() returns a positive value: " + CPU.GetAmountOfRAM()); + } + + public void TestMultibootMemoryMap() + { + var memoryMap = CPU.GetMemoryMap(); + for (int i = 0; i < memoryMap.Length; i++) + { + mDebugger.Send($"Memory Map: {memoryMap[i].Address} " + + $"Length: {memoryMap[i].Length} Type: {memoryMap[i].Type}"); + } + Assert.IsTrue(memoryMap.Length != 0, "Memory Map is not empty! Length " + memoryMap.Length); + } + public void TestMultiboot() { Assert.IsTrue(Multiboot.GetMBIAddress() != 0, $"Multiboot.GetMBIAddress works {Multiboot.GetMBIAddress()}"); diff --git a/source/Cosmos.Core/Bootstrap.cs b/source/Cosmos.Core/Bootstrap.cs index b23955ace..81c1edf36 100644 --- a/source/Cosmos.Core/Bootstrap.cs +++ b/source/Cosmos.Core/Bootstrap.cs @@ -1,4 +1,7 @@ -namespace Cosmos.Core +using Cosmos.Debug.Kernel; +using XSharp; + +namespace Cosmos.Core { /// /// Bootstrap class. Used to invoke pre-boot methods. @@ -22,7 +25,7 @@ /// /// Multiboot header pointer. /// - public static Multiboot.Header* header; + public static Multiboot.Header* MultibootHeader; /// /// VBE mode info pointer. @@ -59,13 +62,10 @@ */ CPU.InitFloat(); - header = (Multiboot.Header*)Multiboot.GetMBIAddress(); + MultibootHeader = (Multiboot.Header*)Multiboot.GetMBIAddress(); - modeinfo = (Core.VBE.ModeInfo*)header->vbeModeInfo; - controllerinfo = (Core.VBE.ControllerInfo*)header->vbeControlInfo; - - // Managed_Memory_System.ManagedMemory.Initialize(); - // Managed_Memory_System.ManagedMemory.SetUpMemoryArea(); + modeinfo = (Core.VBE.ModeInfo*)MultibootHeader->vbeModeInfo; + controllerinfo = (Core.VBE.ControllerInfo*)MultibootHeader->vbeControlInfo; } } } diff --git a/source/Cosmos.Core/CPU.cs b/source/Cosmos.Core/CPU.cs index 26defb248..b2374d334 100644 --- a/source/Cosmos.Core/CPU.cs +++ b/source/Cosmos.Core/CPU.cs @@ -1,5 +1,7 @@ +#define COSMOSDEBUG using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using IL2CPU.API.Attribs; namespace Cosmos.Core @@ -110,8 +112,6 @@ namespace Cosmos.Core return xResult; } - - /// /// Get CPU vendor name. /// @@ -300,7 +300,8 @@ namespace Cosmos.Core if (!(rs == "")) { return rs; - } else + } + else { throw new NotSupportedException(); } @@ -308,8 +309,6 @@ namespace Cosmos.Core throw new NotSupportedException(); } - - /// /// Check if can read CPU ID. Plugged. /// @@ -341,5 +340,107 @@ namespace Cosmos.Core /// ulong value. /// Thrown on fatal error, contact support. internal static ulong ReadFromModelSpecificRegister() => throw new NotImplementedException(); + + /// + /// Checks if Multiboot returned a memory map + /// + /// + public static unsafe bool MemoryMapExists() + { + return (Bootstrap.MultibootHeader->Flags & 1 << 6) == 64; + } + + /// + /// Get the Memory Map Information from Multiboot + /// + /// Returns an array of MemoryMaps containing the Multiboot Memory Map information. The array may have empty values at the end. + public static unsafe MemoryMap[] GetMemoryMap() + { + if (!MemoryMapExists()) + { + throw new Exception("No Memory Map was returned by Multiboot"); + } + var rawMap = new RawMemoryMap[64]; + var currentMap = (RawMemoryMap*)Bootstrap.MultibootHeader->memMapAddress; + int counter = 0; + while ((uint)currentMap < (Bootstrap.MultibootHeader->memMapAddress + Bootstrap.MultibootHeader->memMapLength) && counter < 64) + { + rawMap[counter++] = *currentMap; + currentMap = (RawMemoryMap*)((uint*)currentMap + ((currentMap->Size + 4 )>> 2)); //The size is in bits, not bytes + if (currentMap->Size == 0) + { + break; + } + } + + if (counter >= 64) + { + throw new Exception("Memory Map returned too many segments"); + } + + var entireMap = new MemoryMap[counter]; + for (int i = 0; i < counter; i++) + { + var rawMemoryMap = rawMap[i]; + entireMap[i] = new MemoryMap + { + Address = (ulong)rawMemoryMap.HighBaseAddr << 32 | rawMemoryMap.LowBaseAddr, + Length = (ulong)rawMemoryMap.HighLength << 32 | rawMemoryMap.LowLength, + Type = rawMemoryMap.Type + }; + } + return entireMap; + } + } + + public class MemoryMap + { + /// + /// Base Address of the memory region + /// + public ulong Address; + /// + /// Length in bytes of the region + /// + public ulong Length; + /// + /// Type of RAM in region. 1 is available. 3 is for ACPI. All other is unavailable + /// + public uint Type; + } + + [StructLayout(LayoutKind.Explicit, Size = 24)] + public struct RawMemoryMap + { + /// + /// Size of this entry + /// + [FieldOffset(0)] + public uint Size; + /// + /// Low 32 bits of the base address + /// + [FieldOffset(4)] + public uint LowBaseAddr; + /// + /// High 32 bits of the base address + /// + [FieldOffset(8)] + public uint HighBaseAddr; + /// + /// Low 32 bits of the length of memory block in bytes + /// + [FieldOffset(12)] + public uint LowLength; + /// + /// High 32 bits of the length of memory block in bytes + /// + [FieldOffset(16)] + public uint HighLength; + /// + /// Type of memory area, 1 if usable RAM, everything else unusable. + /// + [FieldOffset(20)] + public uint Type; } } diff --git a/source/Cosmos.Core/MemoryOperations.cs b/source/Cosmos.Core/MemoryOperations.cs index 81c8be230..c66ce56ef 100644 --- a/source/Cosmos.Core/MemoryOperations.cs +++ b/source/Cosmos.Core/MemoryOperations.cs @@ -8,6 +8,7 @@ namespace Cosmos.Core /// public unsafe class MemoryOperations { + #region Fill /// /// Fill memory block. Plugged. /// @@ -183,6 +184,23 @@ namespace Cosmos.Core } } + /// + /// Fill source to destination. + /// + /// Destination. + /// Source. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe void Fill(sbyte[] dest, sbyte[] src) + { + fixed (sbyte* destPtr = dest) + fixed (sbyte* srcPtr = src) + { + Copy(destPtr, srcPtr, dest.Length); + } + } + #endregion Fill + + #region Copy /// /// Copy source to destination. /// plugged. @@ -329,19 +347,6 @@ namespace Cosmos.Core } } - /// - /// Fill source to destination. - /// - /// Destination. - /// Source. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe void Fill(sbyte[] dest, sbyte[] src) - { - fixed (sbyte* destPtr = dest) - fixed (sbyte* srcPtr = src) - { - Copy(destPtr, srcPtr, dest.Length); - } - } + #endregion Copy } } diff --git a/source/Cosmos.Core/Multiboot.cs b/source/Cosmos.Core/Multiboot.cs index 341de394e..99e41484d 100644 --- a/source/Cosmos.Core/Multiboot.cs +++ b/source/Cosmos.Core/Multiboot.cs @@ -139,7 +139,7 @@ namespace Cosmos.Core /// True if is available, false if not public static bool IsAvailable() { - if ((Bootstrap.header->Flags & VBEINFO_PRESENT) == 0) + if ((Bootstrap.MultibootHeader->Flags & VBEINFO_PRESENT) == 0) { return false; } diff --git a/source/Cosmos.Core_Asm/MultibootImpl.cs b/source/Cosmos.Core_Asm/MultibootImpl.cs index c2203981f..bd7153769 100644 --- a/source/Cosmos.Core_Asm/MultibootImpl.cs +++ b/source/Cosmos.Core_Asm/MultibootImpl.cs @@ -19,7 +19,7 @@ namespace Cosmos.Core_Asm { public override void AssembleNew(Assembler aAssembler, object aMethodInfo) { - XS.Push("MultibootSignature"); + XS.Push("MultiBootInfo_Structure", isIndirect: true); } } } From 867b17cf4f26b878c95508228ffc2597b4d18964 Mon Sep 17 00:00:00 2001 From: Quajak Date: Mon, 19 Oct 2020 10:13:56 +0200 Subject: [PATCH 20/27] Removed unnecessary reference to XSharp --- source/Cosmos.Core/Bootstrap.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Cosmos.Core/Bootstrap.cs b/source/Cosmos.Core/Bootstrap.cs index 81c1edf36..c1d3ea4b3 100644 --- a/source/Cosmos.Core/Bootstrap.cs +++ b/source/Cosmos.Core/Bootstrap.cs @@ -1,5 +1,4 @@ using Cosmos.Debug.Kernel; -using XSharp; namespace Cosmos.Core { From 2afcd17c3d95c7dbff8d85f1b26cef25dec8397e Mon Sep 17 00:00:00 2001 From: Quajak Date: Mon, 19 Oct 2020 15:57:35 +0200 Subject: [PATCH 21/27] Fixed typo --- Tests/Kernels/ProcessorTests/Kernel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Kernels/ProcessorTests/Kernel.cs b/Tests/Kernels/ProcessorTests/Kernel.cs index 74b2c79cb..d9f457134 100644 --- a/Tests/Kernels/ProcessorTests/Kernel.cs +++ b/Tests/Kernels/ProcessorTests/Kernel.cs @@ -23,7 +23,7 @@ namespace ProcessorTests try { TestMultibootMemoryMap(); - TetsGetRam(); + TestGetRam(); TestVendorNameIsNotBlank(); TestCycleCount(); TestCycleRateIsNotZero(); @@ -39,7 +39,7 @@ namespace ProcessorTests } } - public void TetsGetRam() + public void TestGetRam() { Assert.IsTrue(CPU.GetAmountOfRAM() > 0, "CPU.GetAmountOfRAM() returns a positive value: " + CPU.GetAmountOfRAM()); } From a28e982d9f831256d3b8142fa1e21062d48ca272 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Mon, 19 Oct 2020 13:41:49 -0500 Subject: [PATCH 22/27] Qemu --- Tests/Cosmos.TestRunner.Core/Engine.Run.cs | 6 +- source/Cosmos.Debug.Hosts/Qemu.cs | 4 +- .../AD7.Impl/AD7Process.cs | 14 +- .../Rules/LaunchConfiguration.xaml | 1 + .../OldCosmosPropertyPageControl.Designer.cs | 281 +++++++++--------- .../OldCosmosPropertyPageControl.cs | 22 +- .../VS/PropertyPages/ProfilePresets.cs | 4 +- 7 files changed, 182 insertions(+), 150 deletions(-) diff --git a/Tests/Cosmos.TestRunner.Core/Engine.Run.cs b/Tests/Cosmos.TestRunner.Core/Engine.Run.cs index 8d1323f8e..7a7cf21e9 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.Run.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.Run.cs @@ -54,15 +54,15 @@ namespace Cosmos.TestRunner.Core case RunTargetEnum.Bochs: RunTask("RunISO", () => RunIsoInBochs(xIsoFile, xHarddiskPath, workingDirectory)); break; + case RunTargetEnum.Qemu: + RunTask("RunISO", () => RunIsoInQemu(xIsoFile, xHarddiskPath, workingDirectory)); + break; case RunTargetEnum.VMware: RunTask("RunISO", () => RunIsoInVMware(xIsoFile, xHarddiskPath)); break; case RunTargetEnum.HyperV: RunTask("RunISO", () => RunIsoInHyperV(xIsoFile, xHarddiskPath)); break; - case RunTargetEnum.Qemu: - RunTask("RunISO", () => RunIsoInQemu(xIsoFile, xHarddiskPath, workingDirectory)); - break; default: throw new ArgumentOutOfRangeException("RunTarget " + configuration.RunTarget + " not implemented!"); } diff --git a/source/Cosmos.Debug.Hosts/Qemu.cs b/source/Cosmos.Debug.Hosts/Qemu.cs index f40b1c34f..821a50027 100644 --- a/source/Cosmos.Debug.Hosts/Qemu.cs +++ b/source/Cosmos.Debug.Hosts/Qemu.cs @@ -35,9 +35,9 @@ namespace Cosmos.Debug.Hosts _harddiskFile = aHarddisk; } - if (aParams.ContainsKey(BuildPropertyNames.IsoFileString)) + if (aParams.ContainsKey("ISOFile")) { - _isoFile = aParams[BuildPropertyNames.IsoFileString]; + _isoFile = aParams["IOSFile"]; } _debugPortString = "Cosmos\\Serial"; diff --git a/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs b/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs index 4e86d79eb..d1ee6f6c6 100644 --- a/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs +++ b/source/Cosmos.VS.DebugEngine/AD7.Impl/AD7Process.cs @@ -281,7 +281,7 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl private void CreateDebugConnector() { mDbgConnector = null; - + mDebugInfo.TryGetValue(BuildPropertyNames.VisualStudioDebugPortString, out var xPort); // using (var xDebug = new StreamWriter(@"e:\debug.info", false)) @@ -557,12 +557,6 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl //((Host.Bochs)mHost).FixBochsConfiguration(new KeyValuePair[] { new KeyValuePair("IsoFileName", mISO) }); break; - case LaunchType.IntelEdison: - mHost = new IntelEdison(mDebugInfo, false); - break; - case LaunchType.HyperV: - mHost = new HyperV(mDebugInfo, false); - break; case LaunchType.Qemu: if (!QemuSupport.QemuEnabled) { @@ -570,6 +564,12 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl } mHost = new Qemu(mDebugInfo, xUseGDB); break; + case LaunchType.IntelEdison: + mHost = new IntelEdison(mDebugInfo, false); + break; + case LaunchType.HyperV: + mHost = new HyperV(mDebugInfo, false); + break; default: throw new Exception("Invalid Launch value: '" + mLaunch + "'."); } diff --git a/source/Cosmos.VS.ProjectSystem/BuildSystem/Rules/LaunchConfiguration.xaml b/source/Cosmos.VS.ProjectSystem/BuildSystem/Rules/LaunchConfiguration.xaml index 0906b9571..aadbcf278 100644 --- a/source/Cosmos.VS.ProjectSystem/BuildSystem/Rules/LaunchConfiguration.xaml +++ b/source/Cosmos.VS.ProjectSystem/BuildSystem/Rules/LaunchConfiguration.xaml @@ -28,6 +28,7 @@ + diff --git a/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/OldCosmosPropertyPageControl.Designer.cs b/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/OldCosmosPropertyPageControl.Designer.cs index 5af38bf08..456d75f83 100644 --- a/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/OldCosmosPropertyPageControl.Designer.cs +++ b/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/OldCosmosPropertyPageControl.Designer.cs @@ -82,6 +82,7 @@ this.tabBochs = new System.Windows.Forms.TabPage(); this.checkStartBochsDebugGui = new System.Windows.Forms.CheckBox(); this.checkEnableBochsDebug = new System.Windows.Forms.CheckBox(); + this.tabQemu = new System.Windows.Forms.TabPage(); this.tabPXE = new System.Windows.Forms.TabPage(); this.butnPxeRefresh = new System.Windows.Forms.Button(); this.comboPxeInterface = new System.Windows.Forms.ComboBox(); @@ -111,14 +112,15 @@ this.tabLaunch.SuspendLayout(); this.tabVMware.SuspendLayout(); this.tabBochs.SuspendLayout(); + this.tabQemu.SuspendLayout(); this.tabPXE.SuspendLayout(); this.tabUSB.SuspendLayout(); this.tabISO.SuspendLayout(); this.tabSlave.SuspendLayout(); this.SuspendLayout(); - // + // // panel1 - // + // this.panel1.Controls.Add(this.lablCurrentProfile); this.panel1.Controls.Add(this.label11); this.panel1.Dock = System.Windows.Forms.DockStyle.Top; @@ -126,27 +128,27 @@ this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(635, 43); this.panel1.TabIndex = 3; - // + // // lablCurrentProfile - // + // this.lablCurrentProfile.AutoSize = true; this.lablCurrentProfile.Location = new System.Drawing.Point(99, 17); this.lablCurrentProfile.Name = "lablCurrentProfile"; this.lablCurrentProfile.Size = new System.Drawing.Size(41, 13); this.lablCurrentProfile.TabIndex = 1; this.lablCurrentProfile.Text = "label12"; - // + // // label11 - // + // this.label11.AutoSize = true; this.label11.Location = new System.Drawing.Point(17, 17); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(76, 13); this.label11.TabIndex = 0; this.label11.Text = "Current Profile:"; - // + // // TabControl1 - // + // this.TabControl1.Controls.Add(this.tabProfile); this.TabControl1.Controls.Add(this.tabCompile); this.TabControl1.Controls.Add(this.tabAssembler); @@ -156,6 +158,7 @@ this.TabControl1.Controls.Add(this.tabVMware); this.TabControl1.Controls.Add(this.tabHyperV); this.TabControl1.Controls.Add(this.tabBochs); + this.TabControl1.Controls.Add(this.tabQemu); this.TabControl1.Controls.Add(this.tabPXE); this.TabControl1.Controls.Add(this.tabUSB); this.TabControl1.Controls.Add(this.tabISO); @@ -167,9 +170,9 @@ this.TabControl1.SelectedIndex = 0; this.TabControl1.Size = new System.Drawing.Size(635, 512); this.TabControl1.TabIndex = 1; - // + // // tabProfile - // + // this.tabProfile.Controls.Add(this.lablPreset); this.tabProfile.Controls.Add(this.panel2); this.tabProfile.Controls.Add(this.lablDeployText); @@ -181,9 +184,9 @@ this.tabProfile.TabIndex = 8; this.tabProfile.Text = "Profile"; this.tabProfile.UseVisualStyleBackColor = true; - // + // // lablPreset - // + // this.lablPreset.AutoSize = true; this.lablPreset.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lablPreset.ForeColor = System.Drawing.SystemColors.HotTrack; @@ -192,9 +195,9 @@ this.lablPreset.Size = new System.Drawing.Size(247, 13); this.lablPreset.TabIndex = 7; this.lablPreset.Text = "** This is a preset. Some options are restricted."; - // + // // panel2 - // + // this.panel2.Controls.Add(this.lboxProfile); this.panel2.Controls.Add(this.toolStrip1); this.panel2.Dock = System.Windows.Forms.DockStyle.Left; @@ -202,9 +205,9 @@ this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(200, 480); this.panel2.TabIndex = 6; - // + // // lboxProfile - // + // this.lboxProfile.Dock = System.Windows.Forms.DockStyle.Fill; this.lboxProfile.FormattingEnabled = true; this.lboxProfile.Location = new System.Drawing.Point(0, 27); @@ -212,9 +215,9 @@ this.lboxProfile.Size = new System.Drawing.Size(200, 453); this.lboxProfile.Sorted = true; this.lboxProfile.TabIndex = 3; - // + // // toolStrip1 - // + // this.toolStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.butnProfileClone, @@ -225,9 +228,9 @@ this.toolStrip1.Size = new System.Drawing.Size(200, 27); this.toolStrip1.TabIndex = 2; this.toolStrip1.Text = "toolStrip1"; - // + // // butnProfileClone - // + // this.butnProfileClone.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.butnProfileClone.Image = ((System.Drawing.Image)(resources.GetObject("butnProfileClone.Image"))); this.butnProfileClone.ImageTransparentColor = System.Drawing.Color.Magenta; @@ -235,9 +238,9 @@ this.butnProfileClone.Size = new System.Drawing.Size(24, 24); this.butnProfileClone.Text = "Clone"; this.butnProfileClone.ToolTipText = "Create a new profile from an existing one."; - // + // // butnProfileDelete - // + // this.butnProfileDelete.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.butnProfileDelete.Image = ((System.Drawing.Image)(resources.GetObject("butnProfileDelete.Image"))); this.butnProfileDelete.ImageTransparentColor = System.Drawing.Color.Magenta; @@ -245,9 +248,9 @@ this.butnProfileDelete.Size = new System.Drawing.Size(24, 24); this.butnProfileDelete.Text = "Delete"; this.butnProfileDelete.ToolTipText = "Delete selected profile"; - // + // // butnProfileRename - // + // this.butnProfileRename.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.butnProfileRename.Image = ((System.Drawing.Image)(resources.GetObject("butnProfileRename.Image"))); this.butnProfileRename.ImageTransparentColor = System.Drawing.Color.Magenta; @@ -255,17 +258,17 @@ this.butnProfileRename.Size = new System.Drawing.Size(24, 24); this.butnProfileRename.Text = "Rename"; this.butnProfileRename.ToolTipText = "Rename selected profile."; - // + // // lablDeployText - // + // this.lablDeployText.Location = new System.Drawing.Point(217, 44); this.lablDeployText.Name = "lablDeployText"; this.lablDeployText.Size = new System.Drawing.Size(228, 137); this.lablDeployText.TabIndex = 4; this.lablDeployText.Text = "label1"; - // + // // lablBuildOnly - // + // this.lablBuildOnly.AutoSize = true; this.lablBuildOnly.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lablBuildOnly.ForeColor = System.Drawing.SystemColors.HotTrack; @@ -274,9 +277,9 @@ this.lablBuildOnly.Size = new System.Drawing.Size(310, 13); this.lablBuildOnly.TabIndex = 3; this.lablBuildOnly.Text = "** This is a build only option. No process will be launched."; - // + // // tabCompile - // + // this.tabCompile.AutoScroll = true; this.tabCompile.Controls.Add(this.labelBinFormat); this.tabCompile.Controls.Add(this.comboBinFormat); @@ -290,10 +293,10 @@ this.tabCompile.TabIndex = 0; this.tabCompile.Text = "Compile"; this.tabCompile.UseVisualStyleBackColor = true; - // + // // labelBinFormat - // - this.labelBinFormat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + // + this.labelBinFormat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.labelBinFormat.AutoSize = true; this.labelBinFormat.Enabled = false; @@ -305,18 +308,18 @@ this.labelBinFormat.TabIndex = 23; this.labelBinFormat.Text = "Bin format:"; this.labelBinFormat.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // + // // comboBinFormat - // + // this.comboBinFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBinFormat.FormattingEnabled = true; this.comboBinFormat.Location = new System.Drawing.Point(34, 136); this.comboBinFormat.Name = "comboBinFormat"; this.comboBinFormat.Size = new System.Drawing.Size(228, 21); this.comboBinFormat.TabIndex = 22; - // + // // comboFramework - // + // this.comboFramework.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboFramework.Enabled = false; this.comboFramework.FormattingEnabled = true; @@ -324,10 +327,10 @@ this.comboFramework.Name = "comboFramework"; this.comboFramework.Size = new System.Drawing.Size(228, 21); this.comboFramework.TabIndex = 5; - // + // // labelFramework - // - this.labelFramework.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + // + this.labelFramework.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.labelFramework.AutoSize = true; this.labelFramework.Enabled = false; @@ -339,9 +342,9 @@ this.labelFramework.TabIndex = 21; this.labelFramework.Text = "Framework:"; this.labelFramework.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // + // // tabAssembler - // + // this.tabAssembler.Controls.Add(this.checkUseInternalAssembler); this.tabAssembler.Controls.Add(this.labelInternalAssembler); this.tabAssembler.Location = new System.Drawing.Point(4, 22); @@ -350,10 +353,10 @@ this.tabAssembler.TabIndex = 10; this.tabAssembler.Text = "Assembler"; this.tabAssembler.UseVisualStyleBackColor = true; - // + // // checkUseInternalAssembler - // - this.checkUseInternalAssembler.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + // + this.checkUseInternalAssembler.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.checkUseInternalAssembler.AutoSize = true; this.checkUseInternalAssembler.Enabled = false; @@ -365,9 +368,9 @@ this.checkUseInternalAssembler.TabIndex = 6; this.checkUseInternalAssembler.Text = "Use Internal Assembler"; this.checkUseInternalAssembler.UseVisualStyleBackColor = true; - // + // // labelInternalAssembler - // + // this.labelInternalAssembler.Enabled = false; this.labelInternalAssembler.Location = new System.Drawing.Point(40, 32); this.labelInternalAssembler.Margin = new System.Windows.Forms.Padding(44, 0, 3, 0); @@ -375,9 +378,9 @@ this.labelInternalAssembler.Size = new System.Drawing.Size(224, 18); this.labelInternalAssembler.TabIndex = 20; this.labelInternalAssembler.Text = "Experimental. Check if you like to crash!"; - // + // // tabDebug - // + // this.tabDebug.AutoScroll = true; this.tabDebug.Controls.Add(this.chckEnableDebugStub); this.tabDebug.Controls.Add(this.panlDebugSettings); @@ -388,9 +391,9 @@ this.tabDebug.TabIndex = 2; this.tabDebug.Text = "Debug"; this.tabDebug.UseVisualStyleBackColor = true; - // + // // chckEnableDebugStub - // + // this.chckEnableDebugStub.AutoSize = true; this.chckEnableDebugStub.Location = new System.Drawing.Point(14, 6); this.chckEnableDebugStub.Name = "chckEnableDebugStub"; @@ -398,9 +401,9 @@ this.chckEnableDebugStub.TabIndex = 7; this.chckEnableDebugStub.Text = "Enable Remote Debugging"; this.chckEnableDebugStub.UseVisualStyleBackColor = true; - // + // // panlDebugSettings - // + // this.panlDebugSettings.Controls.Add(this.stackCorruptionDetectionGroupBox); this.panlDebugSettings.Controls.Add(this.debugLevelGroupBox); this.panlDebugSettings.Controls.Add(this.debugStubGroupBox); @@ -408,9 +411,9 @@ this.panlDebugSettings.Name = "panlDebugSettings"; this.panlDebugSettings.Size = new System.Drawing.Size(280, 400); this.panlDebugSettings.TabIndex = 33; - // + // // stackCorruptionDetectionGroupBox - // + // this.stackCorruptionDetectionGroupBox.Controls.Add(this.label12); this.stackCorruptionDetectionGroupBox.Controls.Add(this.comboStackCorruptionDetectionLevel); this.stackCorruptionDetectionGroupBox.Controls.Add(this.chkEnableStackCorruptionDetection); @@ -419,18 +422,18 @@ this.stackCorruptionDetectionGroupBox.Size = new System.Drawing.Size(260, 90); this.stackCorruptionDetectionGroupBox.TabIndex = 34; this.stackCorruptionDetectionGroupBox.TabStop = false; - // + // // label12 - // + // this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(3, 42); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(85, 13); this.label12.TabIndex = 30; this.label12.Text = "Detection Level:"; - // + // // comboStackCorruptionDetectionLevel - // + // this.comboStackCorruptionDetectionLevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboStackCorruptionDetectionLevel.FormattingEnabled = true; this.comboStackCorruptionDetectionLevel.Location = new System.Drawing.Point(33, 58); @@ -438,9 +441,9 @@ this.comboStackCorruptionDetectionLevel.Size = new System.Drawing.Size(220, 21); this.comboStackCorruptionDetectionLevel.TabIndex = 9; this.comboStackCorruptionDetectionLevel.SelectedIndexChanged += new System.EventHandler(this.stackCorruptionDetectionLevelComboBox_SelectedIndexChanged); - // + // // chkEnableStackCorruptionDetection - // + // this.chkEnableStackCorruptionDetection.AutoSize = true; this.chkEnableStackCorruptionDetection.Location = new System.Drawing.Point(6, 19); this.chkEnableStackCorruptionDetection.Name = "chkEnableStackCorruptionDetection"; @@ -449,9 +452,9 @@ this.chkEnableStackCorruptionDetection.Text = "Enable Stack Corruption Detection"; this.chkEnableStackCorruptionDetection.UseVisualStyleBackColor = true; this.chkEnableStackCorruptionDetection.CheckedChanged += new System.EventHandler(this.chkEnableStacckCorruptionDetection_CheckedChanged); - // + // // debugLevelGroupBox - // + // this.debugLevelGroupBox.Controls.Add(this.comboTraceMode); this.debugLevelGroupBox.Controls.Add(this.label5); this.debugLevelGroupBox.Controls.Add(this.label4); @@ -461,18 +464,18 @@ this.debugLevelGroupBox.Size = new System.Drawing.Size(260, 125); this.debugLevelGroupBox.TabIndex = 34; this.debugLevelGroupBox.TabStop = false; - // + // // comboTraceMode - // + // this.comboTraceMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboTraceMode.FormattingEnabled = true; this.comboTraceMode.Location = new System.Drawing.Point(34, 94); this.comboTraceMode.Name = "comboTraceMode"; this.comboTraceMode.Size = new System.Drawing.Size(220, 21); this.comboTraceMode.TabIndex = 10; - // + // // label5 - // + // this.label5.AutoSize = true; this.label5.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.Location = new System.Drawing.Point(3, 73); @@ -482,9 +485,9 @@ this.label5.TabIndex = 26; this.label5.Text = "Tracing:"; this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // + // // label4 - // + // this.label4.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.Location = new System.Drawing.Point(3, 19); this.label4.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); @@ -493,18 +496,18 @@ this.label4.TabIndex = 24; this.label4.Text = "Debug Level:"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // + // // comboDebugMode - // + // this.comboDebugMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboDebugMode.FormattingEnabled = true; this.comboDebugMode.Location = new System.Drawing.Point(34, 46); this.comboDebugMode.Name = "comboDebugMode"; this.comboDebugMode.Size = new System.Drawing.Size(220, 21); this.comboDebugMode.TabIndex = 9; - // + // // debugStubGroupBox - // + // this.debugStubGroupBox.Controls.Add(this.checkIgnoreDebugStubAttribute); this.debugStubGroupBox.Controls.Add(this.label9); this.debugStubGroupBox.Controls.Add(this.cmboVisualStudioDebugPort); @@ -515,9 +518,9 @@ this.debugStubGroupBox.Size = new System.Drawing.Size(260, 140); this.debugStubGroupBox.TabIndex = 31; this.debugStubGroupBox.TabStop = false; - // + // // checkIgnoreDebugStubAttribute - // + // this.checkIgnoreDebugStubAttribute.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.checkIgnoreDebugStubAttribute.Location = new System.Drawing.Point(6, 19); this.checkIgnoreDebugStubAttribute.Name = "checkIgnoreDebugStubAttribute"; @@ -525,18 +528,18 @@ this.checkIgnoreDebugStubAttribute.TabIndex = 11; this.checkIgnoreDebugStubAttribute.Text = "Ignore DebugStub Attribute Settings"; this.checkIgnoreDebugStubAttribute.UseVisualStyleBackColor = true; - // + // // label9 - // + // this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(6, 42); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(69, 13); this.label9.TabIndex = 29; this.label9.Text = "Cosmos Port:"; - // + // // cmboVisualStudioDebugPort - // + // this.cmboVisualStudioDebugPort.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmboVisualStudioDebugPort.FormattingEnabled = true; this.cmboVisualStudioDebugPort.Items.AddRange(new object[] { @@ -550,9 +553,9 @@ this.cmboVisualStudioDebugPort.Size = new System.Drawing.Size(220, 21); this.cmboVisualStudioDebugPort.Sorted = true; this.cmboVisualStudioDebugPort.TabIndex = 13; - // + // // cmboCosmosDebugPort - // + // this.cmboCosmosDebugPort.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmboCosmosDebugPort.FormattingEnabled = true; this.cmboCosmosDebugPort.Items.AddRange(new object[] { @@ -566,18 +569,18 @@ this.cmboCosmosDebugPort.Size = new System.Drawing.Size(220, 21); this.cmboCosmosDebugPort.Sorted = true; this.cmboCosmosDebugPort.TabIndex = 12; - // + // // label10 - // + // this.label10.AutoSize = true; this.label10.Location = new System.Drawing.Point(6, 90); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(93, 13); this.label10.TabIndex = 30; this.label10.Text = "Visual Studio Port:"; - // + // // tabDeployment - // + // this.tabDeployment.Controls.Add(this.lboxDeployment); this.tabDeployment.Location = new System.Drawing.Point(4, 22); this.tabDeployment.Name = "tabDeployment"; @@ -585,9 +588,9 @@ this.tabDeployment.TabIndex = 11; this.tabDeployment.Text = "Deployment"; this.tabDeployment.UseVisualStyleBackColor = true; - // + // // lboxDeployment - // + // this.lboxDeployment.Dock = System.Windows.Forms.DockStyle.Left; this.lboxDeployment.FormattingEnabled = true; this.lboxDeployment.Location = new System.Drawing.Point(0, 0); @@ -595,9 +598,9 @@ this.lboxDeployment.Size = new System.Drawing.Size(206, 486); this.lboxDeployment.Sorted = true; this.lboxDeployment.TabIndex = 15; - // + // // tabLaunch - // + // this.tabLaunch.Controls.Add(this.lboxLaunch); this.tabLaunch.Location = new System.Drawing.Point(4, 22); this.tabLaunch.Name = "tabLaunch"; @@ -605,9 +608,9 @@ this.tabLaunch.TabIndex = 12; this.tabLaunch.Text = "Launch"; this.tabLaunch.UseVisualStyleBackColor = true; - // + // // lboxLaunch - // + // this.lboxLaunch.Dock = System.Windows.Forms.DockStyle.Left; this.lboxLaunch.FormattingEnabled = true; this.lboxLaunch.Location = new System.Drawing.Point(0, 0); @@ -615,9 +618,9 @@ this.lboxLaunch.Size = new System.Drawing.Size(206, 486); this.lboxLaunch.Sorted = true; this.lboxLaunch.TabIndex = 16; - // + // // tabVMware - // + // this.tabVMware.Controls.Add(this.checkEnableGDB); this.tabVMware.Controls.Add(this.checkStartCosmosGDB); this.tabVMware.Controls.Add(this.label3); @@ -629,9 +632,9 @@ this.tabVMware.TabIndex = 4; this.tabVMware.Text = "VMware"; this.tabVMware.UseVisualStyleBackColor = true; - // + // // checkEnableGDB - // + // this.checkEnableGDB.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.checkEnableGDB.Location = new System.Drawing.Point(9, 77); this.checkEnableGDB.Name = "checkEnableGDB"; @@ -639,9 +642,9 @@ this.checkEnableGDB.TabIndex = 19; this.checkEnableGDB.Text = "Enable GDB Debugger"; this.checkEnableGDB.UseVisualStyleBackColor = true; - // + // // checkStartCosmosGDB - // + // this.checkStartCosmosGDB.AutoSize = true; this.checkStartCosmosGDB.Enabled = false; this.checkStartCosmosGDB.Location = new System.Drawing.Point(24, 103); @@ -651,18 +654,18 @@ this.checkStartCosmosGDB.TabIndex = 20; this.checkStartCosmosGDB.Text = "Use Cosmos GDB Client"; this.checkStartCosmosGDB.UseVisualStyleBackColor = true; - // + // // label3 - // + // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(6, 12); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(42, 13); this.label3.TabIndex = 18; this.label3.Text = "Edition:"; - // + // // cmboVMwareEdition - // + // this.cmboVMwareEdition.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmboVMwareEdition.FormattingEnabled = true; this.cmboVMwareEdition.Location = new System.Drawing.Point(26, 37); @@ -670,9 +673,9 @@ this.cmboVMwareEdition.Size = new System.Drawing.Size(143, 21); this.cmboVMwareEdition.Sorted = true; this.cmboVMwareEdition.TabIndex = 18; - // + // // tabBochs - // + // this.tabBochs.Controls.Add(this.checkStartBochsDebugGui); this.tabBochs.Controls.Add(this.checkEnableBochsDebug); this.tabBochs.Location = new System.Drawing.Point(4, 22); @@ -682,9 +685,9 @@ this.tabBochs.TabIndex = 5; this.tabBochs.Text = "Bochs"; this.tabBochs.UseVisualStyleBackColor = true; - // + // // checkStartBochsDebugGui - // + // this.checkStartBochsDebugGui.Enabled = false; this.checkStartBochsDebugGui.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.checkStartBochsDebugGui.Location = new System.Drawing.Point(24, 43); @@ -693,9 +696,9 @@ this.checkStartBochsDebugGui.TabIndex = 35; this.checkStartBochsDebugGui.Text = "Use Bochs Debugger GUI"; this.checkStartBochsDebugGui.UseVisualStyleBackColor = true; - // + // // checkEnableBochsDebug - // + // this.checkEnableBochsDebug.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.checkEnableBochsDebug.Location = new System.Drawing.Point(9, 17); this.checkEnableBochsDebug.Name = "checkEnableBochsDebug"; @@ -703,9 +706,19 @@ this.checkEnableBochsDebug.TabIndex = 21; this.checkEnableBochsDebug.Text = "Enable Bochs Debugger"; this.checkEnableBochsDebug.UseVisualStyleBackColor = true; - // + // + // tabQemu + // + this.tabQemu.Location = new System.Drawing.Point(4, 22); + this.tabQemu.Name = "tabQemu"; + this.tabQemu.Padding = new System.Windows.Forms.Padding(3); + this.tabQemu.Size = new System.Drawing.Size(627, 486); + this.tabQemu.TabIndex = 5; + this.tabQemu.Text = "Qemu"; + this.tabQemu.UseVisualStyleBackColor = true; + // // tabPXE - // + // this.tabPXE.Controls.Add(this.butnPxeRefresh); this.tabPXE.Controls.Add(this.comboPxeInterface); this.tabPXE.Controls.Add(this.label1); @@ -716,9 +729,9 @@ this.tabPXE.TabIndex = 6; this.tabPXE.Text = "PXE"; this.tabPXE.UseVisualStyleBackColor = true; - // + // // butnPxeRefresh - // + // this.butnPxeRefresh.AutoSize = true; this.butnPxeRefresh.Image = ((System.Drawing.Image)(resources.GetObject("butnPxeRefresh.Image"))); this.butnPxeRefresh.Location = new System.Drawing.Point(177, 31); @@ -727,25 +740,25 @@ this.butnPxeRefresh.Size = new System.Drawing.Size(23, 23); this.butnPxeRefresh.TabIndex = 23; this.butnPxeRefresh.UseVisualStyleBackColor = true; - // + // // comboPxeInterface - // + // this.comboPxeInterface.Location = new System.Drawing.Point(28, 32); this.comboPxeInterface.Name = "comboPxeInterface"; this.comboPxeInterface.Size = new System.Drawing.Size(146, 21); this.comboPxeInterface.TabIndex = 22; - // + // // label1 - // + // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(13, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(52, 13); this.label1.TabIndex = 0; this.label1.Text = "Interface:"; - // + // // tabUSB - // + // this.tabUSB.Controls.Add(this.label7); this.tabUSB.Location = new System.Drawing.Point(4, 22); this.tabUSB.Name = "tabUSB"; @@ -754,18 +767,18 @@ this.tabUSB.TabIndex = 7; this.tabUSB.Text = "USB"; this.tabUSB.UseVisualStyleBackColor = true; - // + // // label7 - // + // this.label7.Location = new System.Drawing.Point(16, 15); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(375, 102); this.label7.TabIndex = 1; this.label7.Text = "There are no current USB options. The target drive will be requested when you run" + " the project."; - // + // // tabISO - // + // this.tabISO.Controls.Add(this.label8); this.tabISO.Location = new System.Drawing.Point(4, 22); this.tabISO.Name = "tabISO"; @@ -774,17 +787,17 @@ this.tabISO.TabIndex = 8; this.tabISO.Text = "ISO"; this.tabISO.UseVisualStyleBackColor = true; - // + // // label8 - // + // this.label8.Location = new System.Drawing.Point(17, 16); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(375, 102); this.label8.TabIndex = 1; this.label8.Text = "There are currently no ISO options."; - // + // // tabSlave - // + // this.tabSlave.Controls.Add(this.cmboSlavePort); this.tabSlave.Controls.Add(this.label6); this.tabSlave.Location = new System.Drawing.Point(4, 22); @@ -794,9 +807,9 @@ this.tabSlave.TabIndex = 13; this.tabSlave.Text = "Slave"; this.tabSlave.UseVisualStyleBackColor = true; - // + // // cmboSlavePort - // + // this.cmboSlavePort.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmboSlavePort.FormattingEnabled = true; this.cmboSlavePort.Items.AddRange(new object[] { @@ -810,18 +823,18 @@ this.cmboSlavePort.Size = new System.Drawing.Size(146, 21); this.cmboSlavePort.Sorted = true; this.cmboSlavePort.TabIndex = 23; - // + // // label6 - // + // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(15, 15); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(59, 13); this.label6.TabIndex = 34; this.label6.Text = "Slave Port:"; - // + // // tabHyperV - // + // this.tabHyperV.Location = new System.Drawing.Point(4, 22); this.tabHyperV.Name = "tabHyperV"; this.tabHyperV.Padding = new System.Windows.Forms.Padding(3); @@ -829,9 +842,9 @@ this.tabHyperV.TabIndex = 14; this.tabHyperV.Text = "Hyper-V"; this.tabHyperV.UseVisualStyleBackColor = true; - // + // // CosmosPage - // + // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.TabControl1); @@ -865,6 +878,7 @@ this.tabVMware.ResumeLayout(false); this.tabVMware.PerformLayout(); this.tabBochs.ResumeLayout(false); + this.tabQemu.ResumeLayout(false); this.tabPXE.ResumeLayout(false); this.tabPXE.PerformLayout(); this.tabUSB.ResumeLayout(false); @@ -909,6 +923,7 @@ private System.Windows.Forms.CheckBox checkIgnoreDebugStubAttribute; private System.Windows.Forms.TabPage tabBochs; private System.Windows.Forms.CheckBox checkEnableBochsDebug; + private System.Windows.Forms.TabPage tabQemu; private System.Windows.Forms.TabPage tabVMware; private System.Windows.Forms.CheckBox checkEnableGDB; private System.Windows.Forms.CheckBox checkStartCosmosGDB; diff --git a/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/OldCosmosPropertyPageControl.cs b/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/OldCosmosPropertyPageControl.cs index ca090899e..dd9d423e0 100644 --- a/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/OldCosmosPropertyPageControl.cs +++ b/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/OldCosmosPropertyPageControl.cs @@ -36,6 +36,7 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages protected int mHyperVDebugPipe; protected bool mShowTabBochs; + protected bool mShowTabQemu; protected bool mShowTabDebug; protected bool mShowTabDeployment; protected bool mShowTabLaunch; @@ -98,8 +99,8 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages if (xValue != mViewModel.BuildProperties.Launch) { mViewModel.BuildProperties.Launch = xValue; - // Bochs requires an ISO. Force Deployment property. - if (LaunchType.Bochs == xValue) + // Bochs and Qemu requires an ISO. Force Deployment property. + if (xValue == LaunchType.Bochs) { if (DeploymentType.ISO != mViewModel.BuildProperties.Deployment) { @@ -329,6 +330,7 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages RemoveTab(tabISO); RemoveTab(tabSlave); RemoveTab(tabBochs); + RemoveTab(tabQemu); if (mShowTabDebug) { @@ -372,6 +374,10 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages { TabControl1.TabPages.Add(tabBochs); } + if (mShowTabQemu) + { + TabControl1.TabPages.Add(tabQemu); + } if (TabControl1.TabPages.Contains(xTab)) { @@ -435,6 +441,15 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages cmboVisualStudioDebugPort.Enabled = false; cmboVisualStudioDebugPort.SelectedIndex = mVMwareAndBochsDebugPipe; } + else if (mViewModel.BuildProperties.Profile == "Qemu") + { + mShowTabQemu = true; + chckEnableDebugStub.Checked = true; + chkEnableStackCorruptionDetection.Checked = true; + cmboCosmosDebugPort.Enabled = false; + cmboVisualStudioDebugPort.Enabled = false; + cmboVisualStudioDebugPort.SelectedIndex = mVMwareAndBochsDebugPipe; + } else if (mViewModel.BuildProperties.Profile == "IntelEdison") { mShowTabBochs = false; @@ -513,7 +528,8 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages mShowTabVMware = mViewModel.BuildProperties.Launch == LaunchType.VMware; mShowTabHyperV = mViewModel.BuildProperties.Launch == LaunchType.HyperV; mShowTabSlave = mViewModel.BuildProperties.Launch == LaunchType.Slave; - mShowTabBochs = (LaunchType.Bochs == mViewModel.BuildProperties.Launch); + mShowTabBochs = mViewModel.BuildProperties.Launch == LaunchType.Bochs; + mShowTabQemu = mViewModel.BuildProperties.Launch == LaunchType.Qemu; // UpdateTabs(); } diff --git a/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/ProfilePresets.cs b/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/ProfilePresets.cs index 9f9e6e5fb..2514cafcf 100644 --- a/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/ProfilePresets.cs +++ b/source/Cosmos.VS.ProjectSystem/ProjectSystem/VS/PropertyPages/ProfilePresets.cs @@ -15,12 +15,12 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages { Add("Bochs", "Bochs"); } - Add("IntelEdison", "Intel Edison Serial boot"); - Add("HyperV", "Hyper-V"); if (QemuSupport.QemuEnabled) { Add("Qemu", "Qemu"); } + Add("IntelEdison", "Intel Edison Serial boot"); + Add("HyperV", "Hyper-V"); } } } From 101340a6ed95fdeabd234349a1cde6343345829b Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Tue, 20 Oct 2020 15:54:01 +0200 Subject: [PATCH 23/27] Implement Bitmap Scaling Implement Bitmap Scaling by Desired Height and Width --- source/Cosmos.System2/Graphics/Canvas.cs | 43 +++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/source/Cosmos.System2/Graphics/Canvas.cs b/source/Cosmos.System2/Graphics/Canvas.cs index 427f1d084..223f6c44e 100644 --- a/source/Cosmos.System2/Graphics/Canvas.cs +++ b/source/Cosmos.System2/Graphics/Canvas.cs @@ -855,7 +855,48 @@ namespace Cosmos.System.Graphics } } } - + + /// + /// Draw a Scaled Bitmap. + /// + /// Image to Scale. + /// X coordinate. + /// Y coordinate. + /// Desired Width. + /// Desired Height. + private int[] scaleImage(Image image, int newWidth, int newHeight) + { + int[] pixels = image.rawData; + int w1 = (int)image.Width; + int h1 = (int)image.Height; + int[] temp = new int[newWidth * newHeight]; + int x_ratio = (int)((w1 << 16) / newWidth) + 1; + int y_ratio = (int)((h1 << 16) / newHeight) + 1; + int x2, y2; + for (int i = 0; i < newHeight; i++) + { + for (int j = 0; j < newWidth; j++) + { + x2 = ((j * x_ratio) >> 16); + y2 = ((i * y_ratio) >> 16); + temp[(i * newWidth) + j] = pixels[(y2 * w1) + x2]; + } + } + return temp; + } + public virtual void DrawScaledImage(Image image, int x, int y,int w,int h) + { + int[] pixels = scaleImage(image, w, h); + for (int _x = 0; _x < w; _x++) + { + for (int _y = 0; _y < h; _y++) + { + Global.mDebugger.SendInternal(pixels[_x + _y * w]); + DrawPoint(new Pen(Color.FromArgb(pixels[_x + _y * w])), x + _x, y + _y); + } + } + } + /// /// Draw image with alpha channel. /// From b797255548a1f500863a4bff571c7aeb973f637b Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Tue, 20 Oct 2020 15:56:53 +0200 Subject: [PATCH 24/27] Add Scaling Test --- Tests/Kernels/GraphicTest/Kernel.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/Kernels/GraphicTest/Kernel.cs b/Tests/Kernels/GraphicTest/Kernel.cs index d6a6a4351..61951432c 100644 --- a/Tests/Kernels/GraphicTest/Kernel.cs +++ b/Tests/Kernels/GraphicTest/Kernel.cs @@ -117,7 +117,9 @@ namespace GraphicTest aCanvas.DrawImage(bitmap, new Point(0, 0)); aCanvas.DrawImage(bitmap2, new Point(200, 0)); - + //Scale Bitmap + aCanvas.DrawScaledImage(bitmap,0,0,50,50); + aCanvas.DrawImageAlpha(bitmap3, new Point(0, 300)); /* Drawing ellipses */ From 7cf12663e48358101c770aab3ecd4df06d6bd90f Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Tue, 20 Oct 2020 16:33:07 +0200 Subject: [PATCH 25/27] Update Canvas.cs Make Requested Changes --- source/Cosmos.System2/Graphics/Canvas.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/Cosmos.System2/Graphics/Canvas.cs b/source/Cosmos.System2/Graphics/Canvas.cs index 223f6c44e..bd5d6efca 100644 --- a/source/Cosmos.System2/Graphics/Canvas.cs +++ b/source/Cosmos.System2/Graphics/Canvas.cs @@ -856,14 +856,6 @@ namespace Cosmos.System.Graphics } } - /// - /// Draw a Scaled Bitmap. - /// - /// Image to Scale. - /// X coordinate. - /// Y coordinate. - /// Desired Width. - /// Desired Height. private int[] scaleImage(Image image, int newWidth, int newHeight) { int[] pixels = image.rawData; @@ -884,7 +876,15 @@ namespace Cosmos.System.Graphics } return temp; } - public virtual void DrawScaledImage(Image image, int x, int y,int w,int h) + /// + /// Draw a Scaled Bitmap. + /// + /// Image to Scale. + /// X coordinate. + /// Y coordinate. + /// Desired Width. + /// Desired Height. + public virtual void DrawImage(Image image, int x, int y,int w,int h) { int[] pixels = scaleImage(image, w, h); for (int _x = 0; _x < w; _x++) From 9435168e13db7cd20cbeaa9e68dcfe008f3bd092 Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Tue, 20 Oct 2020 16:46:05 +0200 Subject: [PATCH 26/27] Update Kernel.cs Forgot that --- Tests/Kernels/GraphicTest/Kernel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Kernels/GraphicTest/Kernel.cs b/Tests/Kernels/GraphicTest/Kernel.cs index 61951432c..ab9d54f59 100644 --- a/Tests/Kernels/GraphicTest/Kernel.cs +++ b/Tests/Kernels/GraphicTest/Kernel.cs @@ -118,7 +118,7 @@ namespace GraphicTest aCanvas.DrawImage(bitmap, new Point(0, 0)); aCanvas.DrawImage(bitmap2, new Point(200, 0)); //Scale Bitmap - aCanvas.DrawScaledImage(bitmap,0,0,50,50); + aCanvas.DrawImage(bitmap,0,0,50,50); aCanvas.DrawImageAlpha(bitmap3, new Point(0, 300)); From 0e98b1d7a34dea051e7d01bf59ee30daa5468e8f Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Tue, 20 Oct 2020 12:34:07 -0500 Subject: [PATCH 27/27] Bump Common package version --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 1023084ed..7e7948729 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -30,7 +30,7 @@ - 0.1.0-build18 + 0.1.0-build37 0.1.0-build355 0.1.0-build562