Skip to content

Commit

Permalink
Progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
mterwoord committed Aug 5, 2015
1 parent 2762604 commit e030f5b
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 16 deletions.
2 changes: 0 additions & 2 deletions source/Cosmos.Core/CPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.Core/Heap.Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
;
}
Expand Down
13 changes: 11 additions & 2 deletions source/Cosmos.Core/Heap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -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.
Expand All @@ -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;
}
Expand All @@ -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);

Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions source/Cosmos.HAL/DefaultKeyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace Cosmos.HAL

public class DefaultKeyboard : Keyboard
{
public DefaultKeyboard()
{
}

protected override void Initialize()
{
Expand All @@ -20,8 +23,6 @@ protected override void Initialize()

private List<KeyMapping> mKeys;



private void updateLed()
{
IO.Port60.Byte = 0xED;
Expand Down
5 changes: 3 additions & 2 deletions source/Cosmos.HAL/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions source/Cosmos.HAL/TextScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }
Expand Down
11 changes: 6 additions & 5 deletions source/Cosmos.IL2CPU/VTablesImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion source/Cosmos.System/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

0 comments on commit e030f5b

Please sign in to comment.