From e8eae64425a7d97f4c6d6eacd70dbca48732fbfa Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Thu, 11 Jun 2020 14:17:50 -0500 Subject: [PATCH 1/5] Add DebugMode parameter --- .../Cosmos.TestRunner.Core/Engine.Helpers.cs | 2 +- Tests/Cosmos.TestRunner.Core/Engine.cs | 1 + .../IEngineConfiguration.cs | 1 + .../DefaultEngineConfiguration.cs | 1 + .../EngineConfiguration.cs | 1 + Tests/Cosmos.TestRunner/.vscode/launch.json | 25 ----------- Tests/Cosmos.TestRunner/.vscode/tasks.json | 42 ------------------- 7 files changed, 5 insertions(+), 68 deletions(-) delete mode 100644 Tests/Cosmos.TestRunner/.vscode/launch.json delete mode 100644 Tests/Cosmos.TestRunner/.vscode/tasks.json diff --git a/Tests/Cosmos.TestRunner.Core/Engine.Helpers.cs b/Tests/Cosmos.TestRunner.Core/Engine.Helpers.cs index 4a74a7df1..37e52b1ab 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.Helpers.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.Helpers.cs @@ -216,7 +216,7 @@ namespace Cosmos.TestRunner.Core "EnableDebug:True", "EnableStackCorruptionDetection:" + EnableStackCorruptionChecks, "StackCorruptionDetectionLevel:" + StackCorruptionDetectionLevel, - "DebugMode:Source", + "DebugMode:" + DebugMode, "TraceAssemblies:" + TraceAssembliesLevel, "DebugCom:1", "TargetAssembly:" + kernelFileName, diff --git a/Tests/Cosmos.TestRunner.Core/Engine.cs b/Tests/Cosmos.TestRunner.Core/Engine.cs index 815c6ec04..911e0fc89 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.cs @@ -19,6 +19,7 @@ namespace Cosmos.TestRunner.Core protected TraceAssemblies TraceAssembliesLevel => mConfiguration.TraceAssembliesLevel; protected bool EnableStackCorruptionChecks => mConfiguration.EnableStackCorruptionChecks; protected StackCorruptionDetectionLevel StackCorruptionDetectionLevel => mConfiguration.StackCorruptionDetectionLevel; + protected DebugMode DebugMode => mConfiguration.DebugMode; protected bool RunWithGDB => mConfiguration.RunWithGDB; protected bool StartBochsDebugGui => mConfiguration.StartBochsDebugGUI; diff --git a/Tests/Cosmos.TestRunner.Core/IEngineConfiguration.cs b/Tests/Cosmos.TestRunner.Core/IEngineConfiguration.cs index 050283bb4..ca4ad8ddd 100644 --- a/Tests/Cosmos.TestRunner.Core/IEngineConfiguration.cs +++ b/Tests/Cosmos.TestRunner.Core/IEngineConfiguration.cs @@ -28,6 +28,7 @@ namespace Cosmos.TestRunner.Core TraceAssemblies TraceAssembliesLevel { get; } bool EnableStackCorruptionChecks { get; } StackCorruptionDetectionLevel StackCorruptionDetectionLevel { get; } + DebugMode DebugMode { get; } /// /// An enumerable of kernel assemblies which will be run. diff --git a/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs b/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs index 34eac84ed..09ffe9ab6 100644 --- a/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs +++ b/Tests/Cosmos.TestRunner.Full/DefaultEngineConfiguration.cs @@ -28,6 +28,7 @@ namespace Cosmos.TestRunner.Full public virtual TraceAssemblies TraceAssembliesLevel => TraceAssemblies.User; public virtual bool EnableStackCorruptionChecks => true; public virtual StackCorruptionDetectionLevel StackCorruptionDetectionLevel => StackCorruptionDetectionLevel.AllInstructions; + public virtual DebugMode DebugMode => DebugMode.Source; public virtual IEnumerable KernelAssembliesToRun { diff --git a/Tests/Cosmos.TestRunner.TestAdapter/EngineConfiguration.cs b/Tests/Cosmos.TestRunner.TestAdapter/EngineConfiguration.cs index 31cfceff6..4d01c3763 100644 --- a/Tests/Cosmos.TestRunner.TestAdapter/EngineConfiguration.cs +++ b/Tests/Cosmos.TestRunner.TestAdapter/EngineConfiguration.cs @@ -20,6 +20,7 @@ namespace Cosmos.TestRunner.TestAdapter public TraceAssemblies TraceAssembliesLevel { get; } public bool EnableStackCorruptionChecks { get; } public StackCorruptionDetectionLevel StackCorruptionDetectionLevel { get; } + public DebugMode DebugMode { get; } public IEnumerable KernelAssembliesToRun { get; } diff --git a/Tests/Cosmos.TestRunner/.vscode/launch.json b/Tests/Cosmos.TestRunner/.vscode/launch.json deleted file mode 100644 index b1e73178b..000000000 --- a/Tests/Cosmos.TestRunner/.vscode/launch.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/Cosmos.TestRunner.dll", - "args": [], - "cwd": "${workspaceFolder}", - "console": "internalConsole", - "stopAtEntry": false - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" - } - ] -} \ No newline at end of file diff --git a/Tests/Cosmos.TestRunner/.vscode/tasks.json b/Tests/Cosmos.TestRunner/.vscode/tasks.json deleted file mode 100644 index bd652ecd7..000000000 --- a/Tests/Cosmos.TestRunner/.vscode/tasks.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "dotnet", - "type": "process", - "args": [ - "build", - "${workspaceFolder}/Cosmos.TestRunner.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "publish", - "command": "dotnet", - "type": "process", - "args": [ - "publish", - "${workspaceFolder}/Cosmos.TestRunner.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "watch", - "command": "dotnet", - "type": "process", - "args": [ - "watch", - "run", - "${workspaceFolder}/Cosmos.TestRunner.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - } - ] -} \ No newline at end of file From f00a7e137d2267306368de1ac6463550563c0f48 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Tue, 7 Jul 2020 13:15:07 -0500 Subject: [PATCH 2/5] Add debugmode to test runner ui --- .../ViewModels/SettingsDialogViewModel.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Tests/Cosmos.TestRunner.UI/ViewModels/SettingsDialogViewModel.cs b/Tests/Cosmos.TestRunner.UI/ViewModels/SettingsDialogViewModel.cs index c9373df66..6a5d712b0 100644 --- a/Tests/Cosmos.TestRunner.UI/ViewModels/SettingsDialogViewModel.cs +++ b/Tests/Cosmos.TestRunner.UI/ViewModels/SettingsDialogViewModel.cs @@ -97,6 +97,13 @@ namespace Cosmos.TestRunner.UI.ViewModels set => SetProperty(ref mStackCorruptionDetectionLevel, value); } + private DebugMode mDebugMode = defaultEngineConfiguration.DebugMode; + public DebugMode DebugMode + { + get => mDebugMode; + set => SetProperty(ref mDebugMode, value); + } + public IEnumerable KernelAssembliesToRun { get From 945c0e544b1fa6c16e33128b36850930aa50def8 Mon Sep 17 00:00:00 2001 From: Sam Nadol Date: Fri, 25 Sep 2020 18:46:44 -0400 Subject: [PATCH 3/5] Add Brand String method to CPU.cs --- source/Cosmos.Core/CPU.cs | 71 +++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/source/Cosmos.Core/CPU.cs b/source/Cosmos.Core/CPU.cs index cda877076..93e1ea70a 100644 --- a/source/Cosmos.Core/CPU.cs +++ b/source/Cosmos.Core/CPU.cs @@ -110,6 +110,8 @@ namespace Cosmos.Core return xResult; } + + /// /// Get CPU vendor name. /// @@ -179,15 +181,15 @@ namespace Cosmos.Core { ReadCPUID(0x80000002 + i, ref eax, ref ebx, ref ecx, ref edx); s += (char)(ebx % 256); - s += (char)((ebx >> 8) % 256); - s += (char)((ebx>> 16) % 256); - s += (char)((ebx >> 24) % 256); + s += (char)((ebx >> 8) % 256); + s += (char)((ebx >> 16) % 256); + s += (char)((ebx >> 24) % 256); s += (char)(edx % 256); - s += (char)((edx >> 8) % 256); - s += (char)((edx >> 16) % 256); - s += (char)((edx >> 24) % 256); + s += (char)((edx >> 8) % 256); + s += (char)((edx >> 16) % 256); + s += (char)((edx >> 24) % 256); s += (char)(ecx % 256); - s += (char)((ecx >> 8) % 256); + s += (char)((ecx >> 8) % 256); s += (char)((ecx >> 16) % 256); s += (char)((ecx >> 24) % 256); } @@ -247,6 +249,61 @@ namespace Cosmos.Core throw new NotSupportedException(); } + /// + /// Get CPU cycle speed. + /// + /// long value. + /// Thrown on fatal error, contact support. + /// Thrown if can not read CPU ID. + public static string GetCPUBrandString() + { + if (CanReadCPUID() != 0) + { + // See https://c9x.me/x86/html/file_module_x86_id_45.html + + int eax = 0; + int ebx = 0; + int ecx = 0; + int edx = 0; + int[] s = new int[64]; + string rs = ""; + + for (uint i = 0; i < 3; i++) + { + ReadCPUID(0x80000002 + i, ref eax, ref ebx, ref ecx, ref edx); + s[(i * 16) + 0] = (eax % 256); + s[(i * 16) + 1] = ((eax >> 8) % 256); + s[(i * 16) + 2] = ((eax >> 16) % 256); + s[(i * 16) + 3] = ((eax >> 24) % 256); + s[(i * 16) + 4] = (ebx % 256); + s[(i * 16) + 5] = ((ebx >> 8) % 256); + s[(i * 16) + 6] = ((ebx >> 16) % 256); + s[(i * 16) + 7] = ((ebx >> 24) % 256); + s[(i * 16) + 8] = (ecx % 256); + s[(i * 16) + 9] = ((ecx >> 8) % 256); + s[(i * 16) + 10] = ((ecx >> 16) % 256); + s[(i * 16) + 11] = ((ecx >> 24) % 256); + s[(i * 16) + 12] = (edx % 256); + s[(i * 16) + 13] = ((edx >> 8) % 256); + s[(i * 16) + 14] = ((edx >> 16) % 256); + s[(i * 16) + 15] = ((edx >> 24) % 256); + } + for (int i = 0; i < s.Length; i++) + { + if (s[i] == 0x00) + { + continue; + } + rs += (char)s[i]; + } + return rs; + } + + throw new NotSupportedException(); + } + + + /// /// Check if can read CPU ID. Plugged. /// From eefba351dcc559b3adb11152d2b5963134467a48 Mon Sep 17 00:00:00 2001 From: Sam Nadol Date: Fri, 25 Sep 2020 19:35:48 -0400 Subject: [PATCH 4/5] Add throw if string empty --- source/Cosmos.Core/CPU.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/Cosmos.Core/CPU.cs b/source/Cosmos.Core/CPU.cs index 93e1ea70a..a2618bcf7 100644 --- a/source/Cosmos.Core/CPU.cs +++ b/source/Cosmos.Core/CPU.cs @@ -296,9 +296,15 @@ namespace Cosmos.Core } rs += (char)s[i]; } - return rs; - } + if (!(rs == "")) + { + return rs; + } else + { + throw new NotSupportedException(); + } + } throw new NotSupportedException(); } From a728acb5c889bbf52b3724dead645db1b6557963 Mon Sep 17 00:00:00 2001 From: Sam Nadol Date: Fri, 25 Sep 2020 20:04:48 -0400 Subject: [PATCH 5/5] IsBlank method --- Tests/Kernels/ProcessorTests/Kernel.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tests/Kernels/ProcessorTests/Kernel.cs b/Tests/Kernels/ProcessorTests/Kernel.cs index 93f9588cc..9ef432177 100644 --- a/Tests/Kernels/ProcessorTests/Kernel.cs +++ b/Tests/Kernels/ProcessorTests/Kernel.cs @@ -36,6 +36,14 @@ namespace ProcessorTests } } + public void TestBrandStringBlank() + { + string brandString = CPU.GetCPUBrandString(); + mDebugger.Send("Brand String: " + brandString); + bool isBrandStringBlank = string.IsNullOrWhiteSpace(brandString); + Assert.IsFalse(isBrandStringBlank, "Processor brand string is blank."); + } + public void TestVendorNameIsNotBlank() { string vendorName = CPU.GetCPUVendorName();