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;