From 0b5490a281eb58924924fe81c6e101b22986f1e9 Mon Sep 17 00:00:00 2001 From: Matthijs ter Woord Date: Tue, 18 Aug 2015 20:19:36 +0200 Subject: [PATCH] Ongoing changes. --- .../Kernel.cs | 1 + .../DefaultEngineConfiguration.cs | 8 +++---- .../Cosmos.TestRunner.Core/Engine.Helpers.cs | 4 ++-- source/Cosmos.HAL/Global.cs | 15 ++++++++---- source/Cosmos.HAL/Keyboard.cs | 4 ++++ source/Cosmos.HAL/PS2Keyboard.cs | 24 ++++++++++++------- source/Cosmos.HAL/ScanMapBase.cs | 6 +++++ source/Cosmos.IL2CPU/IL/Ldelem_Ref.cs | 1 + source/Cosmos.System/TestingHelpers.cs | 10 +++++++- 9 files changed, 52 insertions(+), 21 deletions(-) diff --git a/Tests/Cosmos.Compiler.Tests.SingleEchoTest/Kernel.cs b/Tests/Cosmos.Compiler.Tests.SingleEchoTest/Kernel.cs index dd6193908..cf1324581 100644 --- a/Tests/Cosmos.Compiler.Tests.SingleEchoTest/Kernel.cs +++ b/Tests/Cosmos.Compiler.Tests.SingleEchoTest/Kernel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using Cosmos.Debug.Kernel; using Sys = Cosmos.System; namespace Cosmos.Compiler.Tests.SingleEchoTest diff --git a/Tests/Cosmos.TestRunner.Core/DefaultEngineConfiguration.cs b/Tests/Cosmos.TestRunner.Core/DefaultEngineConfiguration.cs index c1387ef14..3f664d624 100644 --- a/Tests/Cosmos.TestRunner.Core/DefaultEngineConfiguration.cs +++ b/Tests/Cosmos.TestRunner.Core/DefaultEngineConfiguration.cs @@ -22,10 +22,10 @@ namespace Cosmos.TestRunner.Core //engine.RunIL2CPUInProcess = true; engine.RunWithGDB = false; - engine.AddKernel(typeof(Cosmos.Compiler.Tests.SimpleWriteLine.Kernel.Kernel).Assembly.Location); - engine.AddKernel(typeof(SimpleStructsAndArraysTest.Kernel).Assembly.Location); - engine.AddKernel(typeof(VGACompilerCrash.Kernel).Assembly.Location); - //engine.AddKernel(typeof(Cosmos.Compiler.Tests.SingleEchoTest.Kernel).Assembly.Location); + //engine.AddKernel(typeof(Cosmos.Compiler.Tests.SimpleWriteLine.Kernel.Kernel).Assembly.Location); + //engine.AddKernel(typeof(SimpleStructsAndArraysTest.Kernel).Assembly.Location); + //engine.AddKernel(typeof(VGACompilerCrash.Kernel).Assembly.Location); + engine.AddKernel(typeof(Cosmos.Compiler.Tests.SingleEchoTest.Kernel).Assembly.Location); // known bugs, therefor disabled for now: //engine.AddKernel(typeof(BoxingTests.Kernel).Assembly.Location); diff --git a/Tests/Cosmos.TestRunner.Core/Engine.Helpers.cs b/Tests/Cosmos.TestRunner.Core/Engine.Helpers.cs index a4c911285..bb08e09aa 100644 --- a/Tests/Cosmos.TestRunner.Core/Engine.Helpers.cs +++ b/Tests/Cosmos.TestRunner.Core/Engine.Helpers.cs @@ -40,8 +40,8 @@ namespace Cosmos.TestRunner.Core { var xArguments = new[] { - "DebugEnabled:True", - "StackCorruptionDetectionEnabled:false", + "DebugEnabled:true", + "StackCorruptionDetectionEnabled:true", "DebugMode:Source", "TraceAssemblies:", "DebugCom:1", diff --git a/source/Cosmos.HAL/Global.cs b/source/Cosmos.HAL/Global.cs index 497d44411..a1d69574d 100644 --- a/source/Cosmos.HAL/Global.cs +++ b/source/Cosmos.HAL/Global.cs @@ -124,11 +124,16 @@ namespace Cosmos.HAL { TextScreen = textScreen; } - if (keyboard != null) - { - Keyboard = keyboard; - } - Global.Dbg.Send("Before Core.Global.Init"); + if (keyboard == null) + { + Core.Global.Dbg.Send("No keyboard specified!"); + Keyboard = new PS2Keyboard(); + } + else + { + Keyboard = keyboard; + } + Global.Dbg.Send("Before Core.Global.Init"); Core.Global.Init(); Global.Dbg.Send("Static Devices"); InitStaticDevices(); diff --git a/source/Cosmos.HAL/Keyboard.cs b/source/Cosmos.HAL/Keyboard.cs index e087db37c..484fc8442 100644 --- a/source/Cosmos.HAL/Keyboard.cs +++ b/source/Cosmos.HAL/Keyboard.cs @@ -14,9 +14,13 @@ namespace Cosmos.HAL { Debugger.DoSend("Skipping creation of key queue!"); } mQueuedKeys = new Queue(32); + Debugger.DoSend("mQueuedKeys created"); SetKeyLayout(new US_Standard()); + Debugger.DoSend("Keylayout set"); Initialize(); + Debugger.DoSend("Initialized"); UpdateLeds(); + Debugger.DoSend("Leds updated"); } /// diff --git a/source/Cosmos.HAL/PS2Keyboard.cs b/source/Cosmos.HAL/PS2Keyboard.cs index 319f97726..28381b2d7 100644 --- a/source/Cosmos.HAL/PS2Keyboard.cs +++ b/source/Cosmos.HAL/PS2Keyboard.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Cosmos.Common.Extensions; using Cosmos.Core; +using Cosmos.Debug.Kernel; namespace Cosmos.HAL { @@ -31,15 +32,16 @@ namespace Cosmos.HAL public override void UpdateLeds() { - IO.Port60.Byte = 0xED; - while ((new IOPort(0x64).Byte & 2) != 0) - { - } - var led_status = (Global.ScrollLock ? 1 : 0) | ((Global.NumLock ? 1 : 0) << 1) | ((Global.CapsLock ? 1 : 0) << 2); - IO.Port60.Byte = (byte)led_status; - while ((new IOPort(0x64).Byte & 2) != 0) - { - } + // for now, lets not do this.. + //IO.Port60.Byte = 0xED; + //while ((new IOPort(0x64).Byte & 2) != 0) + //{ + //} + //var led_status = (Global.ScrollLock ? 1 : 0) | ((Global.NumLock ? 1 : 0) << 1) | ((Global.CapsLock ? 1 : 0) << 2); + //IO.Port60.Byte = (byte)led_status; + //while ((new IOPort(0x64).Byte & 2) != 0) + //{ + //} } protected override void HandleScancode(byte aScancode, bool aReleased) @@ -107,6 +109,10 @@ namespace Cosmos.HAL public bool GetKey(byte aScancode, bool released, out KeyEvent keyInfo) { + if (KeyLayout == null) + { + Debugger.DoSend("No KeyLayout"); + } keyInfo = KeyLayout.ConvertScanCode(aScancode, ControlPressed, ShiftPressed, AltPressed, Global.NumLock, Global.CapsLock, Global.ScrollLock); return keyInfo != null; } diff --git a/source/Cosmos.HAL/ScanMapBase.cs b/source/Cosmos.HAL/ScanMapBase.cs index 920ab1e4a..d758a1595 100644 --- a/source/Cosmos.HAL/ScanMapBase.cs +++ b/source/Cosmos.HAL/ScanMapBase.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Cosmos.Debug.Kernel; namespace Cosmos.HAL { @@ -37,6 +38,11 @@ namespace Cosmos.HAL for (var index = 0; index < _keys.Count; index++) { var t = _keys[index]; + if (t == null) + { + Debugger.DoSend("Key received but item is NULL"); + continue; + } if (t.Scancode == scan) { found = true; diff --git a/source/Cosmos.IL2CPU/IL/Ldelem_Ref.cs b/source/Cosmos.IL2CPU/IL/Ldelem_Ref.cs index ef09ef27c..84aa496ad 100644 --- a/source/Cosmos.IL2CPU/IL/Ldelem_Ref.cs +++ b/source/Cosmos.IL2CPU/IL/Ldelem_Ref.cs @@ -37,6 +37,7 @@ namespace Cosmos.IL2CPU.X86.IL new CPUx86.Pop {DestinationReg = CPUx86.Registers.EDX}; // convert to real memory address new CPUx86.Mov { DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.RegistersEnum.EDX, SourceIsIndirect = true }; + new CPUx86.Add {DestinationReg = CPUx86.Registers.EDX, SourceReg = CPUx86.Registers.EAX}; var xSizeLeft = aElementSize; diff --git a/source/Cosmos.System/TestingHelpers.cs b/source/Cosmos.System/TestingHelpers.cs index fcc5ec673..1692a3eb0 100644 --- a/source/Cosmos.System/TestingHelpers.cs +++ b/source/Cosmos.System/TestingHelpers.cs @@ -1,11 +1,19 @@ -namespace Cosmos.System +using Cosmos.Debug.Kernel; + +namespace Cosmos.System { // This class exists purely for testing purposes. internal static class TestingHelpers { internal static void KeyboardAddFakeScanCode(byte aScanCode, bool aReleased) { + Debugger.DoSend("Before HandleFakeScanCode"); + if (HAL.Global.Keyboard == null) + { + Debugger.DoSend("No Keyboard set!"); + } HAL.Global.Keyboard.HandleFakeScanCode(aScanCode, aReleased); + Debugger.DoSend("After HandleFakeScanCode"); } } }