diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/CPUImpl.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/CPUImpl.cs index 3a601cfbc..dc66218b7 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/CPUImpl.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/CPUImpl.cs @@ -66,6 +66,14 @@ namespace Cosmos.Core.Plugs { [PlugMethod(Assembler = typeof(InitFloatAsm))] public void InitFloat() { } + public class HaltAsm : AssemblerMethod { + public override void AssembleNew(object aAssembler, object aMethodInfo) { + new CPUx86.Halt(); + } + } + [PlugMethod(Assembler = typeof(HaltAsm))] + public void Halt() { } + // [PlugMethod(Assembler = typeof(P2.Assemblers.GetEndOfStack))] // public static uint GetEndOfStack() { diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/Cosmos.Core.Plugs.csproj b/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/Cosmos.Core.Plugs.csproj index 8668b4290..328d7f9d8 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/Cosmos.Core.Plugs.csproj +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core.Plugs/Cosmos.Core.Plugs.csproj @@ -43,8 +43,6 @@ 3.5 - - @@ -54,14 +52,6 @@ - - {B168BEDD-C6A6-4E7C-B9A5-0144286E9E42} - Cosmos.Kernel.Plugs - - - {A1F83D9F-2D44-4264-A08B-416797123018} - Cosmos.Kernel - {94D079E4-3C66-486A-8407-EA6EC049FF53} Cosmos.Compiler.Assembler.X86 diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/CPU.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core/CPU.cs index a187d1be8..3d69c5cbf 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/CPU.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/CPU.cs @@ -7,11 +7,30 @@ namespace Cosmos.Core { // Non hardware class, only used by core and hardware drivers for ports etc. public class CPU { // Amount of RAM in MB's. - public static uint GetAmountOfRAM() { return 0; } // Plugged - public static uint GetEndOfKernel() { return 0; } // Plugged - public static void CreateGDT() { } // Plugged - public static void CreateIDT(bool aEnableInterruptsImmediately) { } // Plugged - public static void InitFloat() { } // Plugged - public static void ZeroFill(uint aStartAddress, uint aLength) { } // Plugged + public uint GetAmountOfRAM() { return 0; } // Plugged + public uint GetEndOfKernel() { return 0; } // Plugged + public void CreateGDT() { } // Plugged + public void CreateIDT(bool aEnableInterruptsImmediately) { } // Plugged + public void InitFloat() { } // Plugged + public void ZeroFill(uint aStartAddress, uint aLength) { } // Plugged + public void Halt() { } // Plugged + + public void Reboot() { + // Disable all interrupts + //DisableInterrupts(); + + //byte temp; + + //// Clear all keyboard buffers + //do { + // temp = CPUBus.Read8(0x64); // Empty user data + // if ((temp & 0x01) != 0) { + // CPUBus.Read8(0x60); // Empty keyboard data + // } + //} while ((temp & 0x02) != 0); + + //CPUBus.Write8(0x64, 0xFE); // Pulse CPU Reset line + Halt(); // If it didn't work, Halt the CPU + } } } diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/Global.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core/Global.cs index 8c56e09ca..c126ec657 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/Global.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/Global.cs @@ -5,12 +5,15 @@ using System.Text; namespace Cosmos.Core { static public class Global { + static public CPU CPU; static readonly public BaseIOGroups BaseIOGroups = new BaseIOGroups(); static readonly public Cosmos.Debug.Kernel.Debugger Dbg = new Cosmos.Debug.Kernel.Debugger("Core", ""); static public PIC PIC; static public Heap Heap; static public void Init() { + CPU = new CPU(); + //Init Heap first - Hardware loads devices and they need heap Console.WriteLine(" Init Heap"); Heap = new Heap(CPU.GetEndOfKernel(), (CPU.GetAmountOfRAM() * 1024 * 1024) - 1024); diff --git a/source2/Kernel/System/Hardware/Core/Cosmos.Core/Heap.cs b/source2/Kernel/System/Hardware/Core/Cosmos.Core/Heap.cs index 817707d42..7f95ba211 100644 --- a/source2/Kernel/System/Hardware/Core/Cosmos.Core/Heap.cs +++ b/source2/Kernel/System/Hardware/Core/Cosmos.Core/Heap.cs @@ -25,7 +25,7 @@ namespace Cosmos.Core { private void ClearMemory(uint aStartAddress, uint aLength) { //TODO: Move to memory. Internal access only... - CPU.ZeroFill(aStartAddress, aLength); + Global.CPU.ZeroFill(aStartAddress, aLength); } private void WriteNumber(uint aNumber, byte aBits) { diff --git a/source2/Kernel/System/Hardware/Cosmos.Hardware/Cosmos.Hardware.csproj b/source2/Kernel/System/Hardware/Cosmos.Hardware/Cosmos.Hardware.csproj index aa6db2dbe..0e1823ba7 100644 --- a/source2/Kernel/System/Hardware/Cosmos.Hardware/Cosmos.Hardware.csproj +++ b/source2/Kernel/System/Hardware/Cosmos.Hardware/Cosmos.Hardware.csproj @@ -53,10 +53,6 @@ - - {A1F83D9F-2D44-4264-A08B-416797123018} - Cosmos.Kernel - {61607F1E-58F9-41CF-972F-128384F3E115} Cosmos.Debug.Kernel diff --git a/source2/Kernel/System/Hardware/Cosmos.Hardware/Keyboard.cs b/source2/Kernel/System/Hardware/Cosmos.Hardware/Keyboard.cs index f05ad8f98..9d759ace7 100644 --- a/source2/Kernel/System/Hardware/Cosmos.Hardware/Keyboard.cs +++ b/source2/Kernel/System/Hardware/Cosmos.Hardware/Keyboard.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using K2 = Cosmos.Kernel; namespace Cosmos.Hardware { public delegate void HandleKeyboardDelegate(byte aScanCode, bool aReleased); @@ -84,7 +83,7 @@ namespace Cosmos.Hardware { default: { if ((mCtrlState) && (mAltState) && (xTheScancode == 0x53)) { Console.WriteLine("Detected Ctrl-Alt-Delete! Rebooting System..."); - Cosmos.Kernel.CPU.Reboot(); + Core.Global.CPU.Reboot(); } if (mShiftState) { xTheScancode = xTheScancode << 16; @@ -348,7 +347,7 @@ namespace Cosmos.Hardware { char xResult = '\0'; while (mBuffer.Count == 0 || !GetCharValue(mBuffer.Dequeue(), out xResult)) { //Global.Sleep(10); //ToDo optimize value - K2.CPU.Halt(); + Core.Global.CPU.Halt(); } return xResult; } @@ -368,7 +367,7 @@ namespace Cosmos.Hardware { ConsoleKey xResult = ConsoleKey.NoName; while (mBuffer.Count == 0 || !GetKeyValue(mBuffer.Dequeue(), out xResult)) { //Global.Sleep(10); //ToDo optimize value - K2.CPU.Halt(); + Core.Global.CPU.Halt(); } return xResult; } @@ -387,7 +386,7 @@ namespace Cosmos.Hardware { KeyMapping xResult = null; while (mBuffer.Count == 0 || !GetKeyMapping(mBuffer.Dequeue(), out xResult)) { //Global.Sleep(10); //ToDo optimize value - K2.CPU.Halt(); + Core.Global.CPU.Halt(); } return xResult; } @@ -404,7 +403,7 @@ namespace Cosmos.Hardware { public uint ReadScancode() { while (mBuffer.Count == 0) { - K2.CPU.Halt(); + Core.Global.CPU.Halt(); } return mBuffer.Dequeue(); diff --git a/source2/Kernel/System/Hardware/Cosmos.Hardware/PIT.cs b/source2/Kernel/System/Hardware/Cosmos.Hardware/PIT.cs index 9f7bffe10..751407e16 100644 --- a/source2/Kernel/System/Hardware/Cosmos.Hardware/PIT.cs +++ b/source2/Kernel/System/Hardware/Cosmos.Hardware/PIT.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using K2 = Cosmos.Kernel; namespace Cosmos.Hardware { public class PIT : Device { @@ -150,7 +149,7 @@ namespace Cosmos.Hardware { RegisterTimer(new PITTimer(SignalWait, (int)(TimeoutMS * 1000000), false)); while (!WaitSignaled) { - K2.CPU.Halt(); + Core.Global.CPU.Halt(); } } public void WaitNS(int TimeoutNS) { @@ -159,7 +158,7 @@ namespace Cosmos.Hardware { RegisterTimer(new PITTimer(SignalWait, TimeoutNS, false)); while (!WaitSignaled) { - K2.CPU.Halt(); + Core.Global.CPU.Halt(); } } diff --git a/source2/Users/Kudzu/Breakpoints/BreakpointsKernel.csproj b/source2/Users/Kudzu/Breakpoints/BreakpointsKernel.csproj index 493030725..4d163cc39 100644 --- a/source2/Users/Kudzu/Breakpoints/BreakpointsKernel.csproj +++ b/source2/Users/Kudzu/Breakpoints/BreakpointsKernel.csproj @@ -41,8 +41,6 @@ - - diff --git a/source2/Users/Kudzu/Notes.html b/source2/Users/Kudzu/Notes.html index 9ba65dcb6..3ede188e3 100644 --- a/source2/Users/Kudzu/Notes.html +++ b/source2/Users/Kudzu/Notes.html @@ -3,10 +3,6 @@

To Do

    -
  • New clean kernel with no links to old one, just console..
      -
    • keyboard PIC GDT CPU CPUBus and plug
    • -
    -
  • Guess Demo
  • use INT3 for BP? Will save 3 bytes per call.. which is a lot...
  • GDB
      @@ -17,14 +13,6 @@
    • Ctrl-c support
  • -
  • Plugs
      -
    • To add a plug
        -
      • Cosmos.Build.MSBuild add ref to the plug asm
      • -
      • IL2CPU.cs - DoInitTypes - do this for any type in the plug asm
      • -
      -
    • -
    -

Matthijs - Next Release