mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 04:48:53 +00:00
Modifying my user kernel to test VMT.
This commit is contained in:
parent
4731098001
commit
53d7432fa0
5 changed files with 148 additions and 148 deletions
|
|
@ -12,7 +12,7 @@ namespace SentinelKernel
|
|||
protected override void BeforeRun()
|
||||
{
|
||||
Console.WriteLine("Cosmos booted successfully.");
|
||||
VFSManager.RegisterVFS(new System.FileSystem.VFS.SentinelVFS());
|
||||
VFSManager.RegisterVFS(new System.FileSystem.VFS.SentinelVFS());
|
||||
}
|
||||
|
||||
protected override void Run()
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
<!-- Looks like this was a mispelled attribute. Replaced by DebugEnabled below.
|
||||
<DebugEnable>true</DebugEnable>
|
||||
-->
|
||||
<DebugEnabled>True</DebugEnabled>
|
||||
<DebugMode>Source</DebugMode>
|
||||
<DebugEnabled>False</DebugEnabled>
|
||||
<DebugMode>IL</DebugMode>
|
||||
<TraceMode>User</TraceMode>
|
||||
<EnableGDB>False</EnableGDB>
|
||||
<StartCosmosGDB>False</StartCosmosGDB>
|
||||
|
|
@ -35,9 +35,9 @@
|
|||
<VMware_Description>Use VMware Player or Workstation to deploy and debug.</VMware_Description>
|
||||
<VMware_Deployment>ISO</VMware_Deployment>
|
||||
<VMware_Launch>VMware</VMware_Launch>
|
||||
<VMware_DebugEnabled>True</VMware_DebugEnabled>
|
||||
<VMware_DebugEnabled>False</VMware_DebugEnabled>
|
||||
<VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled>
|
||||
<VMware_DebugMode>Source</VMware_DebugMode>
|
||||
<VMware_DebugMode>IL</VMware_DebugMode>
|
||||
<VMware_VisualStudioDebugPort>Pipe: Cosmos\Serial</VMware_VisualStudioDebugPort>
|
||||
<VMware_VMwareEdition>Workstation</VMware_VMwareEdition>
|
||||
<VMware_OutputPath>bin\Debug\</VMware_OutputPath>
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ namespace SentinelKernel.System.Plugs.System.IO
|
|||
/// <returns></returns>
|
||||
public static string GetDirectoryName(string aPath)
|
||||
{
|
||||
return "";
|
||||
|
||||
/*
|
||||
if (aPath == null || aPath.Length <= 1)
|
||||
{
|
||||
return "/";
|
||||
|
|
@ -32,7 +29,6 @@ namespace SentinelKernel.System.Plugs.System.IO
|
|||
return aPath;
|
||||
}
|
||||
return aPath.Substring(0, xIndex);
|
||||
*/
|
||||
}
|
||||
|
||||
public static void Cctor(
|
||||
|
|
|
|||
|
|
@ -72,11 +72,11 @@ namespace Cosmos.HAL {
|
|||
|
||||
// Find hardcoded ATA controllers
|
||||
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);
|
||||
|
||||
//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?
|
||||
// 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?
|
||||
|
|
|
|||
|
|
@ -6,32 +6,32 @@ using System.Runtime.InteropServices;
|
|||
|
||||
namespace Cosmos.IL2CPU {
|
||||
// todo: optimize this, probably using assembler
|
||||
public static class VTablesImpl {
|
||||
// this field seems to be always empty, but the VTablesImpl class is embedded in the final exe.
|
||||
public static VTable[] mTypes;
|
||||
public static bool IsInstance(int aObjectType, int aDesiredObjectType) {
|
||||
int xCurrentType = aObjectType;
|
||||
if (aObjectType == 0) {
|
||||
return true;
|
||||
}
|
||||
do {
|
||||
if (xCurrentType == aDesiredObjectType) {
|
||||
return true;
|
||||
}
|
||||
if (xCurrentType == mTypes[xCurrentType].BaseTypeIdentifier) {
|
||||
return false;
|
||||
}
|
||||
xCurrentType = mTypes[xCurrentType].BaseTypeIdentifier;
|
||||
} while (xCurrentType != 0);
|
||||
return false;
|
||||
}
|
||||
public static class VTablesImpl {
|
||||
// this field seems to be always empty, but the VTablesImpl class is embedded in the final exe.
|
||||
public static VTable[] mTypes;
|
||||
public static bool IsInstance(int aObjectType, int aDesiredObjectType) {
|
||||
int xCurrentType = aObjectType;
|
||||
if (aObjectType == 0) {
|
||||
return true;
|
||||
}
|
||||
do {
|
||||
if (xCurrentType == aDesiredObjectType) {
|
||||
return true;
|
||||
}
|
||||
if (xCurrentType == mTypes[xCurrentType].BaseTypeIdentifier) {
|
||||
return false;
|
||||
}
|
||||
xCurrentType = mTypes[xCurrentType].BaseTypeIdentifier;
|
||||
} while (xCurrentType != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void LoadTypeTable(int aTypeCount) {
|
||||
mTypes = new VTable[aTypeCount];
|
||||
public static void LoadTypeTable(int aTypeCount) {
|
||||
mTypes = new VTable[aTypeCount];
|
||||
if (mTypes == null) {
|
||||
Console.WriteLine("No array exists!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetTypeInfo(int aType, int aBaseType, int[] aMethodIndexes, int[] aMethodAddresses, int aMethodCount) {
|
||||
//mTypes[aType] = new VTable();
|
||||
|
|
@ -41,113 +41,117 @@ namespace Cosmos.IL2CPU {
|
|||
mTypes[aType].MethodCount = aMethodCount;
|
||||
}
|
||||
|
||||
public static void SetMethodInfo(int aType, int aMethodIndex, int aMethodIdentifier, int aMethodAddress, char[] aName) {
|
||||
mTypes[aType].MethodIndexes[aMethodIndex] = aMethodIdentifier;
|
||||
mTypes[aType].MethodAddresses[aMethodIndex] = aMethodAddress;
|
||||
public static void SetMethodInfo(int aType, int aMethodIndex, int aMethodIdentifier, int aMethodAddress, char[] aName) {
|
||||
mTypes[aType].MethodIndexes[aMethodIndex] = aMethodIdentifier;
|
||||
mTypes[aType].MethodAddresses[aMethodIndex] = aMethodAddress;
|
||||
mTypes[aType].MethodCount = aMethodIndex + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteNumber(uint aValue, byte aBitCount) {
|
||||
uint xValue = aValue;
|
||||
byte xCurrentBits = aBitCount;
|
||||
Console.Write("0x");
|
||||
while (xCurrentBits >= 4) {
|
||||
xCurrentBits -= 4;
|
||||
byte xCurrentDigit = (byte)((xValue >> xCurrentBits) & 0xF);
|
||||
string xDigitString = null;
|
||||
switch (xCurrentDigit) {
|
||||
case 0:
|
||||
xDigitString = "0";
|
||||
goto default;
|
||||
case 1:
|
||||
xDigitString = "1";
|
||||
goto default;
|
||||
case 2:
|
||||
xDigitString = "2";
|
||||
goto default;
|
||||
case 3:
|
||||
xDigitString = "3";
|
||||
goto default;
|
||||
case 4:
|
||||
xDigitString = "4";
|
||||
goto default;
|
||||
case 5:
|
||||
xDigitString = "5";
|
||||
goto default;
|
||||
case 6:
|
||||
xDigitString = "6";
|
||||
goto default;
|
||||
case 7:
|
||||
xDigitString = "7";
|
||||
goto default;
|
||||
case 8:
|
||||
xDigitString = "8";
|
||||
goto default;
|
||||
case 9:
|
||||
xDigitString = "9";
|
||||
goto default;
|
||||
case 10:
|
||||
xDigitString = "A";
|
||||
goto default;
|
||||
case 11:
|
||||
xDigitString = "B";
|
||||
goto default;
|
||||
case 12:
|
||||
xDigitString = "C";
|
||||
goto default;
|
||||
case 13:
|
||||
xDigitString = "D";
|
||||
goto default;
|
||||
case 14:
|
||||
xDigitString = "E";
|
||||
goto default;
|
||||
case 15:
|
||||
xDigitString = "F";
|
||||
goto default;
|
||||
default:
|
||||
Console.Write(xDigitString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void WriteNumber(uint aValue, byte aBitCount) {
|
||||
uint xValue = aValue;
|
||||
byte xCurrentBits = aBitCount;
|
||||
Console.Write("0x");
|
||||
while (xCurrentBits >= 4) {
|
||||
xCurrentBits -= 4;
|
||||
byte xCurrentDigit = (byte)((xValue >> xCurrentBits) & 0xF);
|
||||
string xDigitString = null;
|
||||
switch (xCurrentDigit) {
|
||||
case 0:
|
||||
xDigitString = "0";
|
||||
goto default;
|
||||
case 1:
|
||||
xDigitString = "1";
|
||||
goto default;
|
||||
case 2:
|
||||
xDigitString = "2";
|
||||
goto default;
|
||||
case 3:
|
||||
xDigitString = "3";
|
||||
goto default;
|
||||
case 4:
|
||||
xDigitString = "4";
|
||||
goto default;
|
||||
case 5:
|
||||
xDigitString = "5";
|
||||
goto default;
|
||||
case 6:
|
||||
xDigitString = "6";
|
||||
goto default;
|
||||
case 7:
|
||||
xDigitString = "7";
|
||||
goto default;
|
||||
case 8:
|
||||
xDigitString = "8";
|
||||
goto default;
|
||||
case 9:
|
||||
xDigitString = "9";
|
||||
goto default;
|
||||
case 10:
|
||||
xDigitString = "A";
|
||||
goto default;
|
||||
case 11:
|
||||
xDigitString = "B";
|
||||
goto default;
|
||||
case 12:
|
||||
xDigitString = "C";
|
||||
goto default;
|
||||
case 13:
|
||||
xDigitString = "D";
|
||||
goto default;
|
||||
case 14:
|
||||
xDigitString = "E";
|
||||
goto default;
|
||||
case 15:
|
||||
xDigitString = "F";
|
||||
goto default;
|
||||
default:
|
||||
Console.Write(xDigitString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetMethodAddressForType(int aType, int aMethodIndex) {
|
||||
do {
|
||||
if (mTypes[aType].MethodIndexes == null) {
|
||||
Console.Write("Type ");
|
||||
WriteNumber((uint)aType, 32);
|
||||
Console.WriteLine(", MethodIndexes is null!");
|
||||
while(true) ;
|
||||
}
|
||||
for (int i = 0; i < mTypes[aType].MethodIndexes.Length; i++) {
|
||||
if (mTypes[aType].MethodAddresses == null) {
|
||||
Console.Write("Type ");
|
||||
WriteNumber((uint)aType, 32);
|
||||
Console.WriteLine(", MethodAddresses is null!");
|
||||
while(true) ;
|
||||
}
|
||||
if (mTypes[aType].MethodIndexes[i] == aMethodIndex) {
|
||||
var xResult = mTypes[aType].MethodAddresses[i];
|
||||
if (xResult < 1048576) // if pointer is under 1MB, some issue exists!
|
||||
{
|
||||
Console.Write("Type ");
|
||||
WriteNumber((uint)aType, 32);
|
||||
Console.Write(", MethodIndex = ");
|
||||
WriteNumber((uint)aMethodIndex, 32);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Method found, but address invalid!");
|
||||
while(true) ;
|
||||
}
|
||||
return xResult;
|
||||
}
|
||||
}
|
||||
public static int GetMethodAddressForType(int aType, int aMethodIndex) {
|
||||
do {
|
||||
if (mTypes[aType].MethodIndexes == null) {
|
||||
Console.Write("Type ");
|
||||
WriteNumber((uint)aType, 32);
|
||||
Console.WriteLine(", MethodIndexes is null!");
|
||||
while(true) ;
|
||||
}
|
||||
for (int i = 0; i < mTypes[aType].MethodIndexes.Length; i++) {
|
||||
if (mTypes[aType].MethodAddresses == null) {
|
||||
Console.Write("Type ");
|
||||
WriteNumber((uint)aType, 32);
|
||||
Console.WriteLine(", MethodAddresses is null!");
|
||||
while(true) ;
|
||||
}
|
||||
if (mTypes[aType].MethodIndexes[i] == aMethodIndex) {
|
||||
var xResult = mTypes[aType].MethodAddresses[i];
|
||||
if (xResult < 1048576) // if pointer is under 1MB, some issue exists!
|
||||
{
|
||||
Console.Write("Type ");
|
||||
WriteNumber((uint)aType, 32);
|
||||
Console.Write(", MethodIndex = ");
|
||||
WriteNumber((uint)aMethodIndex, 32);
|
||||
Console.Write(", Result ");
|
||||
WriteNumber((uint)xResult, 32);
|
||||
Console.Write(", i ");
|
||||
WriteNumber((uint)i, 32);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Method found, but address invalid!");
|
||||
while(true) ;
|
||||
}
|
||||
return xResult;
|
||||
}
|
||||
}
|
||||
if (aType == mTypes[aType].BaseTypeIdentifier)
|
||||
{
|
||||
break;
|
||||
}
|
||||
aType = mTypes[aType].BaseTypeIdentifier;
|
||||
} while (true);
|
||||
//}
|
||||
aType = mTypes[aType].BaseTypeIdentifier;
|
||||
} while (true);
|
||||
//}
|
||||
Console.Write("Type ");
|
||||
WriteNumber((uint)aType, 32);
|
||||
Console.Write(", MethodIndex = ");
|
||||
|
|
@ -156,18 +160,18 @@ namespace Cosmos.IL2CPU {
|
|||
Console.WriteLine("Not FOUND!");
|
||||
while (true)
|
||||
;
|
||||
throw new Exception("Cannot find virtual method!");
|
||||
}
|
||||
}
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
||||
public struct VTable {
|
||||
[FieldOffset(0)]
|
||||
public int BaseTypeIdentifier;
|
||||
[FieldOffset(4)]
|
||||
public int MethodCount;
|
||||
[FieldOffset(8)]
|
||||
public int[] MethodIndexes;
|
||||
[FieldOffset(12)]
|
||||
public int[] MethodAddresses;
|
||||
}
|
||||
throw new Exception("Cannot find virtual method!");
|
||||
}
|
||||
}
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
||||
public struct VTable {
|
||||
[FieldOffset(0)]
|
||||
public int BaseTypeIdentifier;
|
||||
[FieldOffset(4)]
|
||||
public int MethodCount;
|
||||
[FieldOffset(8)]
|
||||
public int[] MethodIndexes;
|
||||
[FieldOffset(12)]
|
||||
public int[] MethodAddresses;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue