From 558de4a4d2cab0d877ed0cf12e580d183bd75e87 Mon Sep 17 00:00:00 2001 From: ewoudje Date: Tue, 16 Jan 2018 22:29:57 +0100 Subject: [PATCH] Fixed PIT I am not sure it is how it should work but it works --- source/Cosmos.HAL2/Global.cs | 2 +- source/Cosmos.HAL2/PIT.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/Cosmos.HAL2/Global.cs b/source/Cosmos.HAL2/Global.cs index 6ab841147..9b0dfd95d 100644 --- a/source/Cosmos.HAL2/Global.cs +++ b/source/Cosmos.HAL2/Global.cs @@ -9,7 +9,7 @@ namespace Cosmos.HAL { public static readonly Debugger mDebugger = new Debugger("HAL", "Global"); - //static public PIT PIT = new PIT(); + static public PIT PIT = new PIT(); // Must be static init, other static inits rely on it not being null public static TextScreenBase TextScreen = new TextScreen(); diff --git a/source/Cosmos.HAL2/PIT.cs b/source/Cosmos.HAL2/PIT.cs index b74f1e102..889f020b6 100644 --- a/source/Cosmos.HAL2/PIT.cs +++ b/source/Cosmos.HAL2/PIT.cs @@ -30,19 +30,21 @@ namespace Cosmos.HAL { this.NSRemaining = this.NanosecondsTimeout; this.Recuring = Recuring; } + public PITTimer(dOnTrigger HandleOnTrigger, int NanosecondsTimeout, int NanosecondsLeft) { this.HandleTrigger = HandleOnTrigger; this.NanosecondsTimeout = NanosecondsTimeout; this.NSRemaining = NanosecondsLeft; this.Recuring = true; } + ~PITTimer() { Dispose(); } public void Dispose() { if (ID != -1) { - //Global.PIT.UnregisterTimer(ID); + Global.PIT.UnregisterTimer(ID); } } } @@ -154,9 +156,13 @@ namespace Cosmos.HAL { RegisterTimer(new PITTimer(SignalWait, (int)(TimeoutMS * 1000000), false)); while (!WaitSignaled) { - Core.Global.CPU.Halt(); + var bytes = new byte[1]; + IO.Data0.Read8(bytes); + if (bytes[0] == 0) HandleInterrupt(); + //Core.Global.CPU.Halt(); } } + public void WaitNS(int TimeoutNS) { WaitSignaled = false;