mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-02 06:10:13 +00:00
Merge branch 'master' of https://github.com/CosmosOS/Cosmos
This commit is contained in:
commit
dfff11f4e9
9 changed files with 174 additions and 8 deletions
1
Docs/Kernel/Memory.md
Normal file
1
Docs/Kernel/Memory.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
On initialization of the kernel, a GlobalInformationTable is setup. This contains the address of the first DataLookupEntry
|
||||||
|
|
@ -45,8 +45,12 @@ namespace Cosmos.Compiler.Tests.Bcl.System
|
||||||
|
|
||||||
Assert.IsTrue((val2AsULong == 42), "Int64 to UInt64 conversion does not work");
|
Assert.IsTrue((val2AsULong == 42), "Int64 to UInt64 conversion does not work");
|
||||||
|
|
||||||
|
val2 = long.Parse("42");
|
||||||
|
Assert.IsTrue(val2 == 42, "Parsing Int64 doesn't work.");
|
||||||
|
|
||||||
#if false
|
#if false
|
||||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
|
||||||
|
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||||
result = value.ToString("X2");
|
result = value.ToString("X2");
|
||||||
expectedResult = "0x7FFFFFFFFFFFFFFF";
|
expectedResult = "0x7FFFFFFFFFFFFFFF";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,15 @@ namespace Cosmos.Compiler.Tests.SingleEchoTest
|
||||||
Assert.AreEqual(97, (int) input[0], "First char of returned string is not a!");
|
Assert.AreEqual(97, (int) input[0], "First char of returned string is not a!");
|
||||||
Assert.AreEqual(98, (int)input[1], "Second char of returned string is not b!");
|
Assert.AreEqual(98, (int)input[1], "Second char of returned string is not b!");
|
||||||
Assert.AreEqual(99, (int)input[2], "Third char of returned string is not c!");
|
Assert.AreEqual(99, (int)input[2], "Third char of returned string is not c!");
|
||||||
|
|
||||||
|
// now test ReadKey:
|
||||||
|
|
||||||
|
// fake a
|
||||||
|
Sys.TestingHelpers.KeyboardAddFakeScanCode(0x1E, false);
|
||||||
|
Sys.TestingHelpers.KeyboardAddFakeScanCode(0x1E, true);
|
||||||
|
|
||||||
|
var xKey = Console.ReadKey();
|
||||||
|
Assert.IsTrue(xKey.Key == ConsoleKey.A, "ReadKey didn't return key A!");
|
||||||
TestController.Completed();
|
TestController.Completed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Cosmos.Core
|
namespace Cosmos.Core
|
||||||
{
|
{
|
||||||
// The DataLookupTable (DLT) basically is a linked list.
|
// The DataLookupTable (DLT) basically is a double linked list.
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
internal unsafe struct DataLookupTable
|
internal unsafe struct DataLookupTable
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ namespace Cosmos.Core
|
||||||
DataLookupTable* xCurrentTable = GlobalSystemInfo.GlobalInformationTable->FirstDataLookupTable;
|
DataLookupTable* xCurrentTable = GlobalSystemInfo.GlobalInformationTable->FirstDataLookupTable;
|
||||||
DataLookupTable* xPreviousTable = null;
|
DataLookupTable* xPreviousTable = null;
|
||||||
uint xResult;
|
uint xResult;
|
||||||
|
#region Loop through existing tables and see if we find a free spot
|
||||||
while (xCurrentTable != null)
|
while (xCurrentTable != null)
|
||||||
{
|
{
|
||||||
mDebugger.SendInternal($"Scanning DataLookupTable {xCurrentTableIdx}");
|
mDebugger.SendInternal($"Scanning DataLookupTable {xCurrentTableIdx}");
|
||||||
|
|
@ -86,6 +87,7 @@ namespace Cosmos.Core
|
||||||
mLastTableIndex = xCurrentTableIdx;
|
mLastTableIndex = xCurrentTableIdx;
|
||||||
mLastEntryIndex = 0;
|
mLastEntryIndex = 0;
|
||||||
}
|
}
|
||||||
|
#endregion Loop through existing tables and see if we find a free spot
|
||||||
|
|
||||||
// no tables found, lets create a new one, and use that
|
// no tables found, lets create a new one, and use that
|
||||||
if (xPreviousTable == null)
|
if (xPreviousTable == null)
|
||||||
|
|
@ -143,6 +145,7 @@ namespace Cosmos.Core
|
||||||
//mDebugger.Trace($"Item.Refcount", xCurrentEntry->Refcount);
|
//mDebugger.Trace($"Item.Refcount", xCurrentEntry->Refcount);
|
||||||
if (xCurrentEntry->Size == 0)
|
if (xCurrentEntry->Size == 0)
|
||||||
{
|
{
|
||||||
|
#region Found an uninitialized entry
|
||||||
mDebugger.SendInternal($"Found an entry at position {(uint)i}");
|
mDebugger.SendInternal($"Found an entry at position {(uint)i}");
|
||||||
// found an entry now. Let's set it
|
// found an entry now. Let's set it
|
||||||
if (aTable->Next != null)
|
if (aTable->Next != null)
|
||||||
|
|
@ -188,11 +191,8 @@ namespace Cosmos.Core
|
||||||
|
|
||||||
aHandle = (uint)xCurrentEntry;
|
aHandle = (uint)xCurrentEntry;
|
||||||
//mDebugger.Trace($"Returning handle ", aHandle);
|
//mDebugger.Trace($"Returning handle ", aHandle);
|
||||||
if (aHandle == 0x0213D185)
|
|
||||||
{
|
|
||||||
mDebugger.SendInternal("Last known one");
|
|
||||||
}
|
|
||||||
mLastEntryIndex = i;
|
mLastEntryIndex = i;
|
||||||
|
#endregion Found an uninitialized entry
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
148
source/Cosmos.HAL/ConsoleKeyExExtensions.cs
Normal file
148
source/Cosmos.HAL/ConsoleKeyExExtensions.cs
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Cosmos.HAL
|
||||||
|
{
|
||||||
|
public static class ConsoleKeyExExtensions
|
||||||
|
{
|
||||||
|
public static ConsoleKey ToConsoleKey(this ConsoleKeyEx keyEx)
|
||||||
|
{
|
||||||
|
switch (keyEx)
|
||||||
|
{
|
||||||
|
case ConsoleKeyEx.NoName:
|
||||||
|
return ConsoleKey.NoName;
|
||||||
|
case ConsoleKeyEx.Escape:
|
||||||
|
return ConsoleKey.Escape;
|
||||||
|
case ConsoleKeyEx.F1:
|
||||||
|
return ConsoleKey.F1;
|
||||||
|
case ConsoleKeyEx.F2:
|
||||||
|
return ConsoleKey.F2;
|
||||||
|
case ConsoleKeyEx.F3:
|
||||||
|
return ConsoleKey.F3;
|
||||||
|
case ConsoleKeyEx.F4:
|
||||||
|
return ConsoleKey.F4;
|
||||||
|
case ConsoleKeyEx.F5:
|
||||||
|
return ConsoleKey.F5;
|
||||||
|
case ConsoleKeyEx.F6:
|
||||||
|
return ConsoleKey.F6;
|
||||||
|
case ConsoleKeyEx.F7:
|
||||||
|
return ConsoleKey.F7;
|
||||||
|
case ConsoleKeyEx.F8:
|
||||||
|
return ConsoleKey.F8;
|
||||||
|
case ConsoleKeyEx.F9:
|
||||||
|
return ConsoleKey.F9;
|
||||||
|
case ConsoleKeyEx.F10:
|
||||||
|
return ConsoleKey.F10;
|
||||||
|
case ConsoleKeyEx.F11:
|
||||||
|
return ConsoleKey.F11;
|
||||||
|
case ConsoleKeyEx.F12:
|
||||||
|
return ConsoleKey.F12;
|
||||||
|
case ConsoleKeyEx.PrintScreen:
|
||||||
|
return ConsoleKey.PrintScreen;
|
||||||
|
case ConsoleKeyEx.D1:
|
||||||
|
return ConsoleKey.D1;
|
||||||
|
case ConsoleKeyEx.D2:
|
||||||
|
return ConsoleKey.D2;
|
||||||
|
case ConsoleKeyEx.D3:
|
||||||
|
return ConsoleKey.D3;
|
||||||
|
case ConsoleKeyEx.D4:
|
||||||
|
return ConsoleKey.D4;
|
||||||
|
case ConsoleKeyEx.D5:
|
||||||
|
return ConsoleKey.D5;
|
||||||
|
case ConsoleKeyEx.D6:
|
||||||
|
return ConsoleKey.D6;
|
||||||
|
case ConsoleKeyEx.D7:
|
||||||
|
return ConsoleKey.D7;
|
||||||
|
case ConsoleKeyEx.D8:
|
||||||
|
return ConsoleKey.D8;
|
||||||
|
case ConsoleKeyEx.D9:
|
||||||
|
return ConsoleKey.D9;
|
||||||
|
case ConsoleKeyEx.D0:
|
||||||
|
return ConsoleKey.D0;
|
||||||
|
case ConsoleKeyEx.Backspace:
|
||||||
|
return ConsoleKey.Backspace;
|
||||||
|
case ConsoleKeyEx.Tab:
|
||||||
|
return ConsoleKey.Tab;
|
||||||
|
case ConsoleKeyEx.Q:
|
||||||
|
return ConsoleKey.Q;
|
||||||
|
case ConsoleKeyEx.W:
|
||||||
|
return ConsoleKey.W;
|
||||||
|
case ConsoleKeyEx.E:
|
||||||
|
return ConsoleKey.E;
|
||||||
|
case ConsoleKeyEx.R:
|
||||||
|
return ConsoleKey.R;
|
||||||
|
case ConsoleKeyEx.T:
|
||||||
|
return ConsoleKey.T;
|
||||||
|
case ConsoleKeyEx.Y:
|
||||||
|
return ConsoleKey.Y;
|
||||||
|
case ConsoleKeyEx.U:
|
||||||
|
return ConsoleKey.U;
|
||||||
|
case ConsoleKeyEx.I:
|
||||||
|
return ConsoleKey.I;
|
||||||
|
case ConsoleKeyEx.O:
|
||||||
|
return ConsoleKey.O;
|
||||||
|
case ConsoleKeyEx.P:
|
||||||
|
return ConsoleKey.P;
|
||||||
|
case ConsoleKeyEx.Enter:
|
||||||
|
return ConsoleKey.Enter;
|
||||||
|
case ConsoleKeyEx.A:
|
||||||
|
return ConsoleKey.A;
|
||||||
|
case ConsoleKeyEx.S:
|
||||||
|
return ConsoleKey.S;
|
||||||
|
case ConsoleKeyEx.D:
|
||||||
|
return ConsoleKey.D;
|
||||||
|
case ConsoleKeyEx.F:
|
||||||
|
return ConsoleKey.F;
|
||||||
|
case ConsoleKeyEx.G:
|
||||||
|
return ConsoleKey.G;
|
||||||
|
case ConsoleKeyEx.H:
|
||||||
|
return ConsoleKey.H;
|
||||||
|
case ConsoleKeyEx.J:
|
||||||
|
return ConsoleKey.J;
|
||||||
|
case ConsoleKeyEx.K:
|
||||||
|
return ConsoleKey.K;
|
||||||
|
case ConsoleKeyEx.L:
|
||||||
|
return ConsoleKey.L;
|
||||||
|
case ConsoleKeyEx.Z:
|
||||||
|
return ConsoleKey.Z;
|
||||||
|
case ConsoleKeyEx.X:
|
||||||
|
return ConsoleKey.X;
|
||||||
|
case ConsoleKeyEx.C:
|
||||||
|
return ConsoleKey.C;
|
||||||
|
case ConsoleKeyEx.V:
|
||||||
|
return ConsoleKey.V;
|
||||||
|
case ConsoleKeyEx.B:
|
||||||
|
return ConsoleKey.B;
|
||||||
|
case ConsoleKeyEx.N:
|
||||||
|
return ConsoleKey.N;
|
||||||
|
case ConsoleKeyEx.M:
|
||||||
|
return ConsoleKey.M;
|
||||||
|
case ConsoleKeyEx.Spacebar:
|
||||||
|
return ConsoleKey.Spacebar;
|
||||||
|
case ConsoleKeyEx.Insert:
|
||||||
|
return ConsoleKey.Insert;
|
||||||
|
case ConsoleKeyEx.Home:
|
||||||
|
return ConsoleKey.Home;
|
||||||
|
case ConsoleKeyEx.PageUp:
|
||||||
|
return ConsoleKey.PageUp;
|
||||||
|
case ConsoleKeyEx.Delete:
|
||||||
|
return ConsoleKey.Delete;
|
||||||
|
case ConsoleKeyEx.End:
|
||||||
|
return ConsoleKey.End;
|
||||||
|
case ConsoleKeyEx.PageDown:
|
||||||
|
return ConsoleKey.PageDown;
|
||||||
|
case ConsoleKeyEx.UpArrow:
|
||||||
|
return ConsoleKey.UpArrow;
|
||||||
|
case ConsoleKeyEx.DownArrow:
|
||||||
|
return ConsoleKey.DownArrow;
|
||||||
|
case ConsoleKeyEx.LeftArrow:
|
||||||
|
return ConsoleKey.LeftArrow;
|
||||||
|
case ConsoleKeyEx.RightArrow:
|
||||||
|
return ConsoleKey.RightArrow;
|
||||||
|
case ConsoleKeyEx.Sleep:
|
||||||
|
return ConsoleKey.Sleep;
|
||||||
|
default:
|
||||||
|
throw new Exception("KeyEx not implemented!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -98,6 +98,7 @@
|
||||||
<Compile Include="BlockDevice\Partition.cs" />
|
<Compile Include="BlockDevice\Partition.cs" />
|
||||||
<Compile Include="Bootstrap.cs" />
|
<Compile Include="Bootstrap.cs" />
|
||||||
<Compile Include="ConsoleKeyEx.cs" />
|
<Compile Include="ConsoleKeyEx.cs" />
|
||||||
|
<Compile Include="ConsoleKeyExExtensions.cs" />
|
||||||
<Compile Include="DebugTextScreen.cs" />
|
<Compile Include="DebugTextScreen.cs" />
|
||||||
<Compile Include="KeyEvent.cs" />
|
<Compile Include="KeyEvent.cs" />
|
||||||
<Compile Include="KeyMapping.cs" />
|
<Compile Include="KeyMapping.cs" />
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Cosmos.Common;
|
using Cosmos.Common;
|
||||||
|
using Cosmos.IL2CPU.Plugs;
|
||||||
|
|
||||||
namespace Cosmos.IL2CPU {
|
namespace Cosmos.IL2CPU {
|
||||||
[DebuggerStepThrough]
|
[DebuggerStepThrough]
|
||||||
|
|
@ -25,6 +26,7 @@ namespace Cosmos.IL2CPU {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PlugMethod(PlugRequired=true)]
|
||||||
public static uint AllocNewObject(uint aSize) {
|
public static uint AllocNewObject(uint aSize) {
|
||||||
// uint xNewObject = RuntimeEngine.Heap_AllocNewObject(aSize + 4);
|
// uint xNewObject = RuntimeEngine.Heap_AllocNewObject(aSize + 4);
|
||||||
//#if GC_DEBUG
|
//#if GC_DEBUG
|
||||||
|
|
|
||||||
|
|
@ -379,7 +379,7 @@ namespace Cosmos.System.Plugs.System
|
||||||
|
|
||||||
// ReadKey() pure CIL
|
// ReadKey() pure CIL
|
||||||
|
|
||||||
public static KeyEvent ReadKey(Boolean intercept)
|
public static ConsoleKeyInfo ReadKey(Boolean intercept)
|
||||||
{
|
{
|
||||||
var key = Cosmos.HAL.Global.Keyboard.ReadKey();
|
var key = Cosmos.HAL.Global.Keyboard.ReadKey();
|
||||||
|
|
||||||
|
|
@ -387,7 +387,8 @@ namespace Cosmos.System.Plugs.System
|
||||||
{
|
{
|
||||||
Write(key.KeyChar);
|
Write(key.KeyChar);
|
||||||
}
|
}
|
||||||
return key;
|
// todo: add support for modifiers (ctrl, alt, etc)
|
||||||
|
return new ConsoleKeyInfo(key.KeyChar, key.Key.ToConsoleKey(), false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String ReadLine()
|
public static String ReadLine()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue