mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 12:30:32 +00:00
This commit is contained in:
parent
f6b7771a3b
commit
374affe053
8 changed files with 26 additions and 20 deletions
|
|
@ -1,11 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Cosmos.Kernel {
|
||||
public class CPU {
|
||||
public static unsafe void Init() {
|
||||
System.Diagnostics.Debugger.Break();
|
||||
Heap.CheckInit();
|
||||
Console.Write("Creating GDT...");
|
||||
Hardware.CPU.CreateGDT();
|
||||
|
|
@ -84,6 +84,7 @@ namespace Cosmos.Kernel {
|
|||
|
||||
static unsafe void TestATA() {
|
||||
Hardware.Storage.ATA.Initialize(Sleep);
|
||||
Debugger.Break();
|
||||
Hardware.Storage.ATA xDrive = new Cosmos.Hardware.Storage.ATA(0, 0);
|
||||
byte* xBuffer = (byte*)Heap.MemAlloc(512);
|
||||
if (xDrive.ReadBlock(1, xBuffer)) {
|
||||
|
|
@ -95,16 +96,16 @@ namespace Cosmos.Kernel {
|
|||
if (xExt2.Initialize()) {
|
||||
Console.WriteLine("Ext2 Initialized");
|
||||
} else {
|
||||
Console.WriteLine("Ext2 Initialization failed!");
|
||||
Console.WriteLine("Ext2 Initialization failed!");
|
||||
}
|
||||
byte[] xItem = xExt2.ReadFile(new string[] { "readme.txt" });
|
||||
//if (xItem == null) {
|
||||
// Console.WriteLine("Couldn't read file!");
|
||||
// return;
|
||||
//}
|
||||
//Console.Write("File length = ");
|
||||
//Hardware.Storage.ATAOld.WriteNumber((uint)xItem.Length, 32);
|
||||
//Console.WriteLine(" bytes");
|
||||
if (xItem == null) {
|
||||
Console.WriteLine("Couldn't read file!");
|
||||
return;
|
||||
}
|
||||
Console.Write("File length = ");
|
||||
Hardware.Storage.ATAOld.WriteNumber((uint)xItem.Length, 32);
|
||||
Console.WriteLine(" bytes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ namespace IL2CPU {
|
|||
public static bool MetalMode;
|
||||
public static bool DebugMode = true;
|
||||
public static TargetPlatformEnum TargetPlatform = TargetPlatformEnum.Win32;
|
||||
public const string LDParamsTemplate_NativeX86 = "-Ttext 0x2000000 -Tdata 0x200000 -e Kernel_Start -o \"{0}\" \"{1}\"";
|
||||
public const string LDParamsTemplate_NativeX86 = "-Ttext 0x400000 -Tdata 0x200000 -e Kernel_Start -o \"{0}\" \"{1}\"";
|
||||
public const string NAsmParamsTemplate_NativeX86 = "-g -f elf -F stabs -o \"{0}\" \"{1}\"";
|
||||
public const string FAsmParamsTemplate_Win32 = "\"{1}\" \"{0}\"";
|
||||
|
||||
|
|
@ -30,7 +30,8 @@ namespace IL2CPU {
|
|||
Console.WriteLine("Indy IL2CPU");
|
||||
Console.WriteLine();
|
||||
foreach (string x in aArgs) {
|
||||
if (x[0] != '-') {
|
||||
// MtW: Slash added for powershell compatibility
|
||||
if (x[0] != '-' && x[0] != '/') {
|
||||
Console.WriteLine("Error parsing arguments. Arguments should start with a dash ('{0}')", x);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
new CPUx86.Pop(CPUx86.Registers.EAX);
|
||||
new CPUx86.Move(CPUx86.Registers.EDX, "0" + aElementSize.ToString("X") + "h");
|
||||
new CPUx86.Multiply(CPUx86.Registers.EDX);
|
||||
new CPUx86.Add(CPUx86.Registers.EAX, "0" + (ObjectImpl.FieldDataOffset + 8).ToString("X") + "h");
|
||||
new CPUx86.Add(CPUx86.Registers.EAX, "0" + (ObjectImpl.FieldDataOffset + 4).ToString("X") + "h");
|
||||
new CPUx86.Pop(CPUx86.Registers.EDX);
|
||||
new CPUx86.Add(CPUx86.Registers.EDX, CPUx86.Registers.EAX);
|
||||
new CPUx86.Move(CPUx86.Registers.EAX, CPUx86.Registers.EDX);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
new CPUx86.Pop(CPUx86.Registers.EAX);
|
||||
new CPUx86.Move(CPUx86.Registers.EDX, "0" + aElementSize.ToString("X") + "h");
|
||||
new CPUx86.Multiply(CPUx86.Registers.EDX);
|
||||
new CPUx86.Add(CPUx86.Registers.EAX, "0" + (ObjectImpl.FieldDataOffset + 8).ToString("X") + "h");
|
||||
new CPUx86.Add(CPUx86.Registers.EAX, "0" + (ObjectImpl.FieldDataOffset + 4).ToString("X") + "h");
|
||||
new CPUx86.Pop(CPUx86.Registers.EDX);
|
||||
new CPUx86.Add(CPUx86.Registers.EDX, CPUx86.Registers.EAX);
|
||||
new CPUx86.Pushd(CPUx86.Registers.EDX);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
Assembler.StackSizes.Push(4);
|
||||
Multiply(Assembler);
|
||||
// the total items size is now on the stack
|
||||
new CPUx86.Pushd("0x" + (ObjectImpl.FieldDataOffset + 8).ToString("X"));
|
||||
new CPUx86.Pushd("0x" + (ObjectImpl.FieldDataOffset + 4).ToString("X"));
|
||||
Assembler.StackSizes.Push(4);
|
||||
Add(Assembler);
|
||||
// the total array size is now on the stack.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Mono.Cecil.Cil;
|
|||
using CPU = Indy.IL2CPU.Assembler;
|
||||
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
||||
using Asm = Indy.IL2CPU.Assembler;
|
||||
using Indy.IL2CPU.Assembler;
|
||||
|
||||
namespace Indy.IL2CPU.IL.X86 {
|
||||
[OpCode(Code.Newobj, false)]
|
||||
|
|
@ -52,12 +53,15 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
new Move("dword", "[eax + 4]", "0" + InstanceTypeEnum.NormalObject.ToString("X") + "h");
|
||||
new Move("dword", "[eax + 8]", "0x" + xGCFieldCount.ToString("X"));
|
||||
if (aCtorDef != null) {
|
||||
MethodInformation xCtorInfo = Engine.GetMethodInfo(aCtorDef, aCtorDef, Label.GenerateLabelName(aCtorDef), Engine.GetTypeInfo(Engine.GetDefinitionFromTypeReference(aCtorDef.DeclaringType)));
|
||||
int xSize = (from item in xCtorInfo.Arguments
|
||||
select item.Size + (item.Size % 4 == 0 ? 0 : (4 - (item.Size % 4)))).Take(xCtorInfo.Arguments.Length - 1).Sum();
|
||||
for (int i = 0; i < aCtorDef.Parameters.Count; i++) {
|
||||
new CPUx86.Pushd("[esp + 0x8]");
|
||||
new CPUx86.Pushd("[esp + 0x" + (xSize + 4).ToString("X") + "]");
|
||||
}
|
||||
new CPUx86.Call(CPU.Label.GenerateLabelName(aCtorDef));
|
||||
new CPUx86.Pop(CPUx86.Registers.EAX);
|
||||
// aAssembler.StackSizes.Pop();
|
||||
// aAssembler.StackSizes.Pop();
|
||||
for (int i = 0; i < aCtorDef.Parameters.Count; i++) {
|
||||
new CPUx86.Add(CPUx86.Registers.ESP, "4");
|
||||
aAssembler.StackSizes.Pop();
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
}
|
||||
new CPUx86.Move(CPUx86.Registers.EBX, "[esp + " + xStackSize + "]"); // the index
|
||||
new CPUx86.Move(CPUx86.Registers.ECX, "[esp + " + (xStackSize + 4) + "]"); // the array
|
||||
new CPUx86.Add(CPUx86.Registers.ECX, (ObjectImpl.FieldDataOffset + 8).ToString());
|
||||
new CPUx86.Add(CPUx86.Registers.ECX, (ObjectImpl.FieldDataOffset + 4).ToString());
|
||||
new CPUx86.Push("0x" + aElementSize.ToString("X"));
|
||||
aAssembler.StackSizes.Push(4);
|
||||
new CPUx86.Push(CPUx86.Registers.EBX);
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ namespace Indy.IL2CPU {
|
|||
/// </para>
|
||||
/// <para>
|
||||
/// The first 4 bytes are the reference to the type information of the instance, the second 4 bytes
|
||||
/// are the <see cref="InstanceTypeEnum"/> value. For arrays, there are 4 following bytes containing the element count.
|
||||
/// and 4 bytes containing the element size.
|
||||
/// are the <see cref="InstanceTypeEnum"/> value. For arrays, there are 4 following bytes containing the element count, for objects, the amount of reference fields.
|
||||
/// For arrays, next 4 bytes containing the element size.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public const int FieldDataOffset = 8;
|
||||
public const int FieldDataOffset = 12;
|
||||
//[MethodAlias(Name = "System_Void___System_Object__ctor____")]
|
||||
public static void Ctor(IntPtr aThis) {
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue