From e030f5b85051c05fab886fcffc372f1b1fd9346c Mon Sep 17 00:00:00 2001 From: Matthijs ter Woord Date: Wed, 5 Aug 2015 17:32:32 -0400 Subject: [PATCH] Progress. --- source/Cosmos.Core/CPU.cs | 2 -- source/Cosmos.Core/Heap.Debug.cs | 4 ++-- source/Cosmos.Core/Heap.cs | 13 +++++++++++-- source/Cosmos.HAL/DefaultKeyboard.cs | 5 +++-- source/Cosmos.HAL/Global.cs | 5 +++-- source/Cosmos.HAL/TextScreen.cs | 1 + source/Cosmos.IL2CPU/VTablesImpl.cs | 11 ++++++----- source/Cosmos.System/Global.cs | 3 ++- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/source/Cosmos.Core/CPU.cs b/source/Cosmos.Core/CPU.cs index 1e2ab0e409..4006c57614 100644 --- a/source/Cosmos.Core/CPU.cs +++ b/source/Cosmos.Core/CPU.cs @@ -73,10 +73,8 @@ private static void DoDisableInterrupts() public static bool mInterruptsEnabled; public static void EnableInterrupts() { - Debugger.DoSend("Enabling interrupts"); mInterruptsEnabled = true; DoEnableInterrupts(); - Debugger.DoSend("After DoEnableInterrupts"); } /// diff --git a/source/Cosmos.Core/Heap.Debug.cs b/source/Cosmos.Core/Heap.Debug.cs index 8f7d71a37c..3c7b00fe4b 100644 --- a/source/Cosmos.Core/Heap.Debug.cs +++ b/source/Cosmos.Core/Heap.Debug.cs @@ -5,7 +5,7 @@ namespace Cosmos.Core { partial class Heap { - public static bool EnableDebug = true; + public static bool EnableDebug = false; private static void Debug(string message) { if (!EnableDebug) @@ -33,7 +33,7 @@ private static void DebugHex(string message, uint value) private static void DebugAndHalt(string message) { - Debug(message); + Debugger.DoSend(message); while (true) ; } diff --git a/source/Cosmos.Core/Heap.cs b/source/Cosmos.Core/Heap.cs index 8dca35ae36..c75923e850 100644 --- a/source/Cosmos.Core/Heap.cs +++ b/source/Cosmos.Core/Heap.cs @@ -58,6 +58,8 @@ public static uint MemAlloc(uint aLength) //DebugHex("At address", (uint)xCurrentTable); if (ScanDataLookupTable(xCurrentTableIdx, xCurrentTable, aLength, out xResult)) { + Debugger.DoSend("Returning handle"); + Debugger.DoSendNumber(xResult); DebugHex("Returning handle ", xResult); if (xResult < CPU.GetEndOfKernel()) { @@ -76,6 +78,7 @@ public static uint MemAlloc(uint aLength) // this check should theoretically be unnecessary, but lets keep it, to do some double-checking. DebugAndHalt("No PreviousTable found!"); } + Debugger.DoSend("Creating new DataLookupTable"); var xLastItem = xPreviousTable->GetEntry(DataLookupTable.EntriesPerTable - 1); var xNextTablePointer = (DataLookupTable*)((uint)xLastItem->DataBlock + xLastItem->Size); // the memory hasn't been cleared yet, so lets do that now. @@ -89,6 +92,8 @@ public static uint MemAlloc(uint aLength) // but couldn't allocate a new handle from it. DebugAndHalt("Something seriously weird happened: we could create a new DataLookupTable (with new entries), but couldn't allocate a new handle from it."); } + Debugger.DoSend("Returning handle"); + Debugger.DoSendNumber(xResult); DebugHex("Returning handle ", xResult); return xResult; } @@ -110,7 +115,7 @@ public static uint MemAlloc(uint aLength) private static bool ScanDataLookupTable(uint aTableIdx, DataLookupTable* aTable, uint aSize, out uint aHandle) { DataLookupEntry* xPreviousEntry = null; - for (int i = 1; i < DataLookupTable.EntriesPerTable; i++) + for (int i = 0; i < DataLookupTable.EntriesPerTable; i++) { var xCurrentEntry = aTable->GetEntry(i); @@ -124,13 +129,17 @@ private static bool ScanDataLookupTable(uint aTableIdx, DataLookupTable* aTable, { // once a handle is used, the size should be set. But at this point, it somehow got unset again. // This should never occur. + Debugger.DoSend("TableIdx"); + Debugger.DoSendNumber(aTableIdx); + Debugger.DoSend("Index"); + Debugger.DoSendNumber((uint)i); DebugAndHalt("Found an entry which has no size, but there is a followup DataLookupTable"); } void* xDataBlock; //Debug("Now calculate datablock pointer"); // now we found ourself a free handle - if (i == 1) + if (i == 0) { //Debug("Using table end"); // we don't have a previous handle yet, so we take the FirstByteAfterTable field of the DataLookupTable diff --git a/source/Cosmos.HAL/DefaultKeyboard.cs b/source/Cosmos.HAL/DefaultKeyboard.cs index 79fd2d0c96..3e82f74c07 100644 --- a/source/Cosmos.HAL/DefaultKeyboard.cs +++ b/source/Cosmos.HAL/DefaultKeyboard.cs @@ -9,6 +9,9 @@ namespace Cosmos.HAL public class DefaultKeyboard : Keyboard { + public DefaultKeyboard() + { + } protected override void Initialize() { @@ -20,8 +23,6 @@ protected override void Initialize() private List mKeys; - - private void updateLed() { IO.Port60.Byte = 0xED; diff --git a/source/Cosmos.HAL/Global.cs b/source/Cosmos.HAL/Global.cs index cffad9a607..9a61a2bb85 100644 --- a/source/Cosmos.HAL/Global.cs +++ b/source/Cosmos.HAL/Global.cs @@ -13,7 +13,7 @@ static public class Global { static public Keyboard Keyboard; //static public PIT PIT = new PIT(); // Must be static init, other static inits rely on it not being null - static public TextScreenBase TextScreen = new TextScreen(); + static public TextScreenBase TextScreen; public static PCI Pci; @@ -120,8 +120,9 @@ static public void Init(TextScreenBase textScreen, Keyboard keyboard) } if (keyboard != null) { - Keyboard = keyboard; + Keyboard = keyboard; } + Global.Dbg.Send("Before Core.Global.Init"); Core.Global.Init(); Global.Dbg.Send("Static Devices"); InitStaticDevices(); diff --git a/source/Cosmos.HAL/TextScreen.cs b/source/Cosmos.HAL/TextScreen.cs index 5c4946fbf3..b3f3de6f19 100644 --- a/source/Cosmos.HAL/TextScreen.cs +++ b/source/Cosmos.HAL/TextScreen.cs @@ -35,6 +35,7 @@ public TextScreen() { mRow2Addr = (UInt32)(Cols * 2); mScrollSize = (UInt32)(Cols * (Rows - 1) * 2); mRowSize32 = (UInt32)Cols * 2 / 4; + Debugger.DoSend("End of TextScreen..ctor"); } public override UInt16 Rows { get { return 25; } } diff --git a/source/Cosmos.IL2CPU/VTablesImpl.cs b/source/Cosmos.IL2CPU/VTablesImpl.cs index ea98766d61..3b2f591e38 100644 --- a/source/Cosmos.IL2CPU/VTablesImpl.cs +++ b/source/Cosmos.IL2CPU/VTablesImpl.cs @@ -75,11 +75,12 @@ public static int GetMethodAddressForType(uint aType, uint aMethodId) { Debug("Oops"); } - DebugHex("Type", aType); + var xCurrentType = aType; + DebugHex("Type", xCurrentType); DebugHex("MethodId", aMethodId); do { - var xCurrentTypeInfo = mTypes[aType]; + var xCurrentTypeInfo = mTypes[xCurrentType]; if (xCurrentTypeInfo.MethodIndexes == null) { @@ -113,17 +114,17 @@ public static int GetMethodAddressForType(uint aType, uint aMethodId) return xResult; } } - if (aType == xCurrentTypeInfo.BaseTypeIdentifier) + if (xCurrentType == xCurrentTypeInfo.BaseTypeIdentifier) { break; } - aType = xCurrentTypeInfo.BaseTypeIdentifier; + xCurrentType = xCurrentTypeInfo.BaseTypeIdentifier; } while (true); //} Debugger.DoSend("Type"); Debugger.DoSendNumber(aType); - Debugger.DoSend("MethodIndex"); + Debugger.DoSend("MethodId"); Debugger.DoSendNumber(aMethodId); Debugger.DoSend("Not FOUND!"); while (true) diff --git a/source/Cosmos.System/Global.cs b/source/Cosmos.System/Global.cs index 74c86e3385..d921fe7625 100644 --- a/source/Cosmos.System/Global.cs +++ b/source/Cosmos.System/Global.cs @@ -20,7 +20,8 @@ static public void Init(TextScreenBase textScreen, Keyboard keyboard){ Global.Dbg.Send("HW Init"); Cosmos.HAL.Global.Init(textScreen, keyboard); - //Network.NetworkStack.Init(); + Global.Dbg.Send("After HW Init"); + //Network.NetworkStack.Init(); } } }