diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/GetAmountOfRAM.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/GetAmountOfRAM.cs index cfbe6189b..84a0da0d4 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/GetAmountOfRAM.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/GetAmountOfRAM.cs @@ -15,7 +15,7 @@ namespace Cosmos.Kernel.Plugs.Assemblers { new CPUx86.Xor(CPUx86.Registers.EDX, CPUx86.Registers.EDX); new CPUx86.Move("ecx", "1024"); new CPUx86.Divide("ecx"); - new CPUx86.Add("eax", "2"); + new CPUx86.Add("eax", "1"); new CPUx86.Pushd(CPUx86.Registers.EAX); } } diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/ZeroFill.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/ZeroFill.cs index e4dda0e22..96720d901 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/ZeroFill.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Assemblers/ZeroFill.cs @@ -2,6 +2,7 @@ using Indy.IL2CPU.Assembler.X86; using Indy.IL2CPU.Plugs; using Assembler = Indy.IL2CPU.Assembler.Assembler; +using CPUAll = Indy.IL2CPU.Assembler; using CPUx86 = Indy.IL2CPU.Assembler.X86; using CPUNative = Indy.IL2CPU.Assembler.X86.Native; @@ -10,10 +11,19 @@ namespace Cosmos.Kernel.Plugs.Assemblers { // public static void ZeroFill(uint aStartAddress, uint aLength) {} public override void Assemble(Assembler aAssembler) { + new CLD(); new CPUx86.Move("edi", "[ebp + 0xC]"); // address new CPUx86.Move("ecx", "[ebp + 8]"); // length new CPUx86.Move("eax", "0"); - new CPUx86.RepeatStosb(); + new CPUx86.ShiftRight("ecx", "ecx", "1"); + new CPUx86.JumpNotCary(".step2"); + new CPUx86.Stosb(); + new CPUAll.Label(".step2"); + new CPUx86.ShiftRight("ecx", "ecx", "1"); + new CPUx86.JumpNotCary(".step3"); + new CPUx86.Stosw(); + new CPUAll.Label(".step3"); + new CPUx86.RepeatStosd(); } } } diff --git a/source/Cosmos/Cosmos.Kernel/Heap.cs b/source/Cosmos/Cosmos.Kernel/Heap.cs index ababe8714..8188e37e9 100644 --- a/source/Cosmos/Cosmos.Kernel/Heap.cs +++ b/source/Cosmos/Cosmos.Kernel/Heap.cs @@ -24,21 +24,34 @@ namespace Cosmos.Kernel { //private const uint DefaultMaxMemory = 32 * 1024 * 1024; private static void ClearMemory(uint aStartAddress, uint aLength) { - int xStart = (RTC.GetMinutes() * 60) + RTC.GetSeconds(); + //int xStart = (RTC.GetMinutes() * 60) + RTC.GetSeconds(); Hardware.CPU.ZeroFill(aStartAddress, aLength); - int xEnd = (RTC.GetMinutes() * 60) + RTC.GetSeconds(); - int xDiff = xEnd - xStart; - Console.Write("Time to clear "); - Hardware.Storage.ATAOld.WriteNumber((uint)xDiff, 32); - Console.WriteLine(""); + //int xEnd = (RTC.GetMinutes() * 60) + RTC.GetSeconds(); + //int xDiff = xEnd - xStart; + //Console.Write("Time to clear "); + //Hardware.Storage.ATAOld.WriteNumber((uint)xDiff, 32); + //Console.WriteLine(""); } - - private static void Initialize(uint aStartAddress, uint aLength) { + + private static void Initialize(uint aStartAddress, uint aEndOfRam) { mStartAddress = aStartAddress + (4 - (aStartAddress % 4)); - mLength = aLength; + mLength = aEndOfRam - aStartAddress; mLength = (mLength / 4) * 4; - mLength -= 1024 * 1024; + mStartAddress += 1024; + mStartAddress = (mStartAddress / 4) * 4; + mLength -= 1024; + Console.Write("Clearing Memory at "); + int xCursorLeft = Console.CursorLeft; + // hack: try to get this working with the full chunk or chunks of 1MB + //const int xBlockSize = 1024*1024; + //for (uint i = 0; i < (mLength / xBlockSize); i++) { + // Console.CursorLeft = xCursorLeft; + // Hardware.Storage.ATAOld.WriteNumber(mStartAddress + (i * xBlockSize), 32); + // ClearMemory(mStartAddress + (i * xBlockSize), xBlockSize); + //} + Console.Write("Clearing Memory...."); ClearMemory(aStartAddress, mLength); + Console.WriteLine("Done"); mFirstBlock = (MemoryBlock*)aStartAddress; mFirstBlock->State = MemoryBlockState.Free; mFirstBlock->Next = (MemoryBlock*)(aStartAddress + mLength); @@ -48,7 +61,8 @@ namespace Cosmos.Kernel { public static void CheckInit() { if (mFirstBlock == null) { - Initialize(Hardware.CPU.EndOfKernel + 4, (Hardware.CPU.AmountOfMemory * 1024 * 1024) - (Hardware.CPU.EndOfKernel + 4)); + //Initialize(Hardware.CPU.EndOfKernel, (Hardware.CPU.AmountOfMemory * 1024 * 1024) - (Hardware.CPU.EndOfKernel + 4)); + Initialize(Hardware.CPU.EndOfKernel, (Hardware.CPU.AmountOfMemory * 1024 * 1024) - 1024); } } diff --git a/source/IL2CPU/Program.cs b/source/IL2CPU/Program.cs index fdbbd04e4..f8db59a31 100644 --- a/source/IL2CPU/Program.cs +++ b/source/IL2CPU/Program.cs @@ -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 0x4000000 -Tdata 0x200000 -e Kernel_Start -o \"{0}\" \"{1}\""; + public const string LDParamsTemplate_NativeX86 = "-Ttext 0x500000 -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}\""; diff --git a/source/Indy.IL2CPU.Assembler.X86/CLD.cs b/source/Indy.IL2CPU.Assembler.X86/CLD.cs new file mode 100644 index 000000000..c3bbfd06b --- /dev/null +++ b/source/Indy.IL2CPU.Assembler.X86/CLD.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Indy.IL2CPU.Assembler.X86 { + [OpCode(0xFFFFFFFF, "cld")] + public class CLD: Instruction { + } +} \ No newline at end of file diff --git a/source/Indy.IL2CPU.Assembler.X86/Indy.IL2CPU.Assembler.X86.csproj b/source/Indy.IL2CPU.Assembler.X86/Indy.IL2CPU.Assembler.X86.csproj index b47c3b4cc..912487687 100644 --- a/source/Indy.IL2CPU.Assembler.X86/Indy.IL2CPU.Assembler.X86.csproj +++ b/source/Indy.IL2CPU.Assembler.X86/Indy.IL2CPU.Assembler.X86.csproj @@ -53,8 +53,11 @@ + + + @@ -86,6 +89,7 @@ + diff --git a/source/Indy.IL2CPU.Assembler.X86/JumpNotCary.cs b/source/Indy.IL2CPU.Assembler.X86/JumpNotCary.cs new file mode 100644 index 000000000..cbe37e1fd --- /dev/null +++ b/source/Indy.IL2CPU.Assembler.X86/JumpNotCary.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Indy.IL2CPU.Assembler.X86 { + [OpCode(0xFFFFFFFF,"jnc")] + public class JumpNotCary: JumpBase { + public JumpNotCary(string aTarget):base(aTarget) { + } + public override string ToString() { + return "jnc " + Address; + } + } +} diff --git a/source/Indy.IL2CPU.Assembler.X86/RepeatStosd.cs b/source/Indy.IL2CPU.Assembler.X86/RepeatStosd.cs index 10de3d81c..63018b98c 100644 --- a/source/Indy.IL2CPU.Assembler.X86/RepeatStosd.cs +++ b/source/Indy.IL2CPU.Assembler.X86/RepeatStosd.cs @@ -11,7 +11,7 @@ namespace Indy.IL2CPU.Assembler.X86 { // Destination = aDestination; } //public override string ToString() { - // return "rep stos " + Destinati; + // return "rep stosddword "; //} } } diff --git a/source/Indy.IL2CPU.Assembler.X86/Stosb.cs b/source/Indy.IL2CPU.Assembler.X86/Stosb.cs new file mode 100644 index 000000000..fd72d556a --- /dev/null +++ b/source/Indy.IL2CPU.Assembler.X86/Stosb.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Indy.IL2CPU.Assembler.X86 { + [OpCode(0xFFFFFFFF, "stosb")] + public class Stosb: Instruction { + } +} \ No newline at end of file diff --git a/source/Indy.IL2CPU.Assembler.X86/Stosw.cs b/source/Indy.IL2CPU.Assembler.X86/Stosw.cs new file mode 100644 index 000000000..8539e1dac --- /dev/null +++ b/source/Indy.IL2CPU.Assembler.X86/Stosw.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Indy.IL2CPU.Assembler.X86 { + [OpCode(0xFFFFFFFF, "stosw")] + public class Stosw: Instruction { + } +} \ No newline at end of file