Modifying my user kernel to test VMT.

This commit is contained in:
unknown 2015-04-17 12:37:29 -05:00
parent 4731098001
commit 53d7432fa0
5 changed files with 148 additions and 148 deletions

View file

@ -12,7 +12,7 @@ namespace SentinelKernel
protected override void BeforeRun() protected override void BeforeRun()
{ {
Console.WriteLine("Cosmos booted successfully."); Console.WriteLine("Cosmos booted successfully.");
VFSManager.RegisterVFS(new System.FileSystem.VFS.SentinelVFS()); VFSManager.RegisterVFS(new System.FileSystem.VFS.SentinelVFS());
} }
protected override void Run() protected override void Run()

View file

@ -18,8 +18,8 @@
<!-- Looks like this was a mispelled attribute. Replaced by DebugEnabled below. <!-- Looks like this was a mispelled attribute. Replaced by DebugEnabled below.
<DebugEnable>true</DebugEnable> <DebugEnable>true</DebugEnable>
--> -->
<DebugEnabled>True</DebugEnabled> <DebugEnabled>False</DebugEnabled>
<DebugMode>Source</DebugMode> <DebugMode>IL</DebugMode>
<TraceMode>User</TraceMode> <TraceMode>User</TraceMode>
<EnableGDB>False</EnableGDB> <EnableGDB>False</EnableGDB>
<StartCosmosGDB>False</StartCosmosGDB> <StartCosmosGDB>False</StartCosmosGDB>
@ -35,9 +35,9 @@
<VMware_Description>Use VMware Player or Workstation to deploy and debug.</VMware_Description> <VMware_Description>Use VMware Player or Workstation to deploy and debug.</VMware_Description>
<VMware_Deployment>ISO</VMware_Deployment> <VMware_Deployment>ISO</VMware_Deployment>
<VMware_Launch>VMware</VMware_Launch> <VMware_Launch>VMware</VMware_Launch>
<VMware_DebugEnabled>True</VMware_DebugEnabled> <VMware_DebugEnabled>False</VMware_DebugEnabled>
<VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled> <VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled>
<VMware_DebugMode>Source</VMware_DebugMode> <VMware_DebugMode>IL</VMware_DebugMode>
<VMware_VisualStudioDebugPort>Pipe: Cosmos\Serial</VMware_VisualStudioDebugPort> <VMware_VisualStudioDebugPort>Pipe: Cosmos\Serial</VMware_VisualStudioDebugPort>
<VMware_VMwareEdition>Workstation</VMware_VMwareEdition> <VMware_VMwareEdition>Workstation</VMware_VMwareEdition>
<VMware_OutputPath>bin\Debug\</VMware_OutputPath> <VMware_OutputPath>bin\Debug\</VMware_OutputPath>

View file

@ -19,9 +19,6 @@ namespace SentinelKernel.System.Plugs.System.IO
/// <returns></returns> /// <returns></returns>
public static string GetDirectoryName(string aPath) public static string GetDirectoryName(string aPath)
{ {
return "";
/*
if (aPath == null || aPath.Length <= 1) if (aPath == null || aPath.Length <= 1)
{ {
return "/"; return "/";
@ -32,7 +29,6 @@ namespace SentinelKernel.System.Plugs.System.IO
return aPath; return aPath;
} }
return aPath.Substring(0, xIndex); return aPath.Substring(0, xIndex);
*/
} }
public static void Cctor( public static void Cctor(

View file

@ -72,11 +72,11 @@ namespace Cosmos.HAL {
// Find hardcoded ATA controllers // Find hardcoded ATA controllers
Global.Dbg.Send("ATA Master"); Global.Dbg.Send("ATA Master");
InitAta(BlockDevice.Ata.ControllerIdEnum.Primary, BlockDevice.Ata.BusPositionEnum.Slave);
Global.Dbg.Send("ATA Slave");
InitAta(BlockDevice.Ata.ControllerIdEnum.Primary, BlockDevice.Ata.BusPositionEnum.Master); InitAta(BlockDevice.Ata.ControllerIdEnum.Primary, BlockDevice.Ata.BusPositionEnum.Master);
//Global.Dbg.Send("ATA Slave");
//InitAta(BlockDevice.Ata.ControllerIdEnum.Primary, BlockDevice.Ata.BusPositionEnum.Slave);
//TODO Need to change code to detect if ATA controllers are present or not. How to do this? via PCI enum? //TODO Need to change code to detect if ATA controllers are present or not. How to do this? via PCI enum?
// They do show up in PCI space as well as the fixed space. // They do show up in PCI space as well as the fixed space.
// Or is it always here, and was our compiler stack corruption issue? // Or is it always here, and was our compiler stack corruption issue?

View file

@ -6,32 +6,32 @@ using System.Runtime.InteropServices;
namespace Cosmos.IL2CPU { namespace Cosmos.IL2CPU {
// todo: optimize this, probably using assembler // todo: optimize this, probably using assembler
public static class VTablesImpl { public static class VTablesImpl {
// this field seems to be always empty, but the VTablesImpl class is embedded in the final exe. // this field seems to be always empty, but the VTablesImpl class is embedded in the final exe.
public static VTable[] mTypes; public static VTable[] mTypes;
public static bool IsInstance(int aObjectType, int aDesiredObjectType) { public static bool IsInstance(int aObjectType, int aDesiredObjectType) {
int xCurrentType = aObjectType; int xCurrentType = aObjectType;
if (aObjectType == 0) { if (aObjectType == 0) {
return true; return true;
} }
do { do {
if (xCurrentType == aDesiredObjectType) { if (xCurrentType == aDesiredObjectType) {
return true; return true;
} }
if (xCurrentType == mTypes[xCurrentType].BaseTypeIdentifier) { if (xCurrentType == mTypes[xCurrentType].BaseTypeIdentifier) {
return false; return false;
} }
xCurrentType = mTypes[xCurrentType].BaseTypeIdentifier; xCurrentType = mTypes[xCurrentType].BaseTypeIdentifier;
} while (xCurrentType != 0); } while (xCurrentType != 0);
return false; return false;
} }
public static void LoadTypeTable(int aTypeCount) { public static void LoadTypeTable(int aTypeCount) {
mTypes = new VTable[aTypeCount]; mTypes = new VTable[aTypeCount];
if (mTypes == null) { if (mTypes == null) {
Console.WriteLine("No array exists!"); Console.WriteLine("No array exists!");
} }
} }
public static void SetTypeInfo(int aType, int aBaseType, int[] aMethodIndexes, int[] aMethodAddresses, int aMethodCount) { public static void SetTypeInfo(int aType, int aBaseType, int[] aMethodIndexes, int[] aMethodAddresses, int aMethodCount) {
//mTypes[aType] = new VTable(); //mTypes[aType] = new VTable();
@ -41,113 +41,117 @@ namespace Cosmos.IL2CPU {
mTypes[aType].MethodCount = aMethodCount; mTypes[aType].MethodCount = aMethodCount;
} }
public static void SetMethodInfo(int aType, int aMethodIndex, int aMethodIdentifier, int aMethodAddress, char[] aName) { public static void SetMethodInfo(int aType, int aMethodIndex, int aMethodIdentifier, int aMethodAddress, char[] aName) {
mTypes[aType].MethodIndexes[aMethodIndex] = aMethodIdentifier; mTypes[aType].MethodIndexes[aMethodIndex] = aMethodIdentifier;
mTypes[aType].MethodAddresses[aMethodIndex] = aMethodAddress; mTypes[aType].MethodAddresses[aMethodIndex] = aMethodAddress;
mTypes[aType].MethodCount = aMethodIndex + 1; mTypes[aType].MethodCount = aMethodIndex + 1;
} }
private static void WriteNumber(uint aValue, byte aBitCount) { private static void WriteNumber(uint aValue, byte aBitCount) {
uint xValue = aValue; uint xValue = aValue;
byte xCurrentBits = aBitCount; byte xCurrentBits = aBitCount;
Console.Write("0x"); Console.Write("0x");
while (xCurrentBits >= 4) { while (xCurrentBits >= 4) {
xCurrentBits -= 4; xCurrentBits -= 4;
byte xCurrentDigit = (byte)((xValue >> xCurrentBits) & 0xF); byte xCurrentDigit = (byte)((xValue >> xCurrentBits) & 0xF);
string xDigitString = null; string xDigitString = null;
switch (xCurrentDigit) { switch (xCurrentDigit) {
case 0: case 0:
xDigitString = "0"; xDigitString = "0";
goto default; goto default;
case 1: case 1:
xDigitString = "1"; xDigitString = "1";
goto default; goto default;
case 2: case 2:
xDigitString = "2"; xDigitString = "2";
goto default; goto default;
case 3: case 3:
xDigitString = "3"; xDigitString = "3";
goto default; goto default;
case 4: case 4:
xDigitString = "4"; xDigitString = "4";
goto default; goto default;
case 5: case 5:
xDigitString = "5"; xDigitString = "5";
goto default; goto default;
case 6: case 6:
xDigitString = "6"; xDigitString = "6";
goto default; goto default;
case 7: case 7:
xDigitString = "7"; xDigitString = "7";
goto default; goto default;
case 8: case 8:
xDigitString = "8"; xDigitString = "8";
goto default; goto default;
case 9: case 9:
xDigitString = "9"; xDigitString = "9";
goto default; goto default;
case 10: case 10:
xDigitString = "A"; xDigitString = "A";
goto default; goto default;
case 11: case 11:
xDigitString = "B"; xDigitString = "B";
goto default; goto default;
case 12: case 12:
xDigitString = "C"; xDigitString = "C";
goto default; goto default;
case 13: case 13:
xDigitString = "D"; xDigitString = "D";
goto default; goto default;
case 14: case 14:
xDigitString = "E"; xDigitString = "E";
goto default; goto default;
case 15: case 15:
xDigitString = "F"; xDigitString = "F";
goto default; goto default;
default: default:
Console.Write(xDigitString); Console.Write(xDigitString);
break; break;
} }
} }
} }
public static int GetMethodAddressForType(int aType, int aMethodIndex) { public static int GetMethodAddressForType(int aType, int aMethodIndex) {
do { do {
if (mTypes[aType].MethodIndexes == null) { if (mTypes[aType].MethodIndexes == null) {
Console.Write("Type "); Console.Write("Type ");
WriteNumber((uint)aType, 32); WriteNumber((uint)aType, 32);
Console.WriteLine(", MethodIndexes is null!"); Console.WriteLine(", MethodIndexes is null!");
while(true) ; while(true) ;
} }
for (int i = 0; i < mTypes[aType].MethodIndexes.Length; i++) { for (int i = 0; i < mTypes[aType].MethodIndexes.Length; i++) {
if (mTypes[aType].MethodAddresses == null) { if (mTypes[aType].MethodAddresses == null) {
Console.Write("Type "); Console.Write("Type ");
WriteNumber((uint)aType, 32); WriteNumber((uint)aType, 32);
Console.WriteLine(", MethodAddresses is null!"); Console.WriteLine(", MethodAddresses is null!");
while(true) ; while(true) ;
} }
if (mTypes[aType].MethodIndexes[i] == aMethodIndex) { if (mTypes[aType].MethodIndexes[i] == aMethodIndex) {
var xResult = mTypes[aType].MethodAddresses[i]; var xResult = mTypes[aType].MethodAddresses[i];
if (xResult < 1048576) // if pointer is under 1MB, some issue exists! if (xResult < 1048576) // if pointer is under 1MB, some issue exists!
{ {
Console.Write("Type "); Console.Write("Type ");
WriteNumber((uint)aType, 32); WriteNumber((uint)aType, 32);
Console.Write(", MethodIndex = "); Console.Write(", MethodIndex = ");
WriteNumber((uint)aMethodIndex, 32); WriteNumber((uint)aMethodIndex, 32);
Console.WriteLine(""); Console.Write(", Result ");
Console.WriteLine("Method found, but address invalid!"); WriteNumber((uint)xResult, 32);
while(true) ; Console.Write(", i ");
} WriteNumber((uint)i, 32);
return xResult; Console.WriteLine("");
} Console.WriteLine("Method found, but address invalid!");
} while(true) ;
}
return xResult;
}
}
if (aType == mTypes[aType].BaseTypeIdentifier) if (aType == mTypes[aType].BaseTypeIdentifier)
{ {
break; break;
} }
aType = mTypes[aType].BaseTypeIdentifier; aType = mTypes[aType].BaseTypeIdentifier;
} while (true); } while (true);
//} //}
Console.Write("Type "); Console.Write("Type ");
WriteNumber((uint)aType, 32); WriteNumber((uint)aType, 32);
Console.Write(", MethodIndex = "); Console.Write(", MethodIndex = ");
@ -156,18 +160,18 @@ namespace Cosmos.IL2CPU {
Console.WriteLine("Not FOUND!"); Console.WriteLine("Not FOUND!");
while (true) while (true)
; ;
throw new Exception("Cannot find virtual method!"); throw new Exception("Cannot find virtual method!");
} }
} }
[StructLayout(LayoutKind.Explicit, Size = 16)] [StructLayout(LayoutKind.Explicit, Size = 16)]
public struct VTable { public struct VTable {
[FieldOffset(0)] [FieldOffset(0)]
public int BaseTypeIdentifier; public int BaseTypeIdentifier;
[FieldOffset(4)] [FieldOffset(4)]
public int MethodCount; public int MethodCount;
[FieldOffset(8)] [FieldOffset(8)]
public int[] MethodIndexes; public int[] MethodIndexes;
[FieldOffset(12)] [FieldOffset(12)]
public int[] MethodAddresses; public int[] MethodAddresses;
} }
} }