memory clearing fixed

This commit is contained in:
mterwoord_cp 2008-01-04 17:32:19 +00:00
parent 2415db0ff7
commit 221815e724
10 changed files with 88 additions and 15 deletions

View file

@ -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);
}
}

View file

@ -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();
}
}
}

View file

@ -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);
}
}

View file

@ -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}\"";

View file

@ -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 {
}
}

View file

@ -53,8 +53,11 @@
<Compile Include="And.cs" />
<Compile Include="Assembler.cs" />
<Compile Include="Call.cs" />
<Compile Include="CLD.cs" />
<Compile Include="CmpXchg.cs" />
<Compile Include="Compare.cs" />
<Compile Include="Stosw.cs" />
<Compile Include="JumpNotCary.cs" />
<Compile Include="RepeatMovsb.cs" />
<Compile Include="RepeatStosd.cs" />
<Compile Include="Interrupt.cs" />
@ -86,6 +89,7 @@
<Compile Include="Pushd.cs" />
<Compile Include="Ret.cs" />
<Compile Include="ShiftRight.cs" />
<Compile Include="Stosb.cs" />
<Compile Include="Sub.cs" />
<Compile Include="Test.cs" />
<Compile Include="Xor.cs" />

View file

@ -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;
}
}
}

View file

@ -11,7 +11,7 @@ namespace Indy.IL2CPU.Assembler.X86 {
// Destination = aDestination;
}
//public override string ToString() {
// return "rep stos " + Destinati;
// return "rep stosddword ";
//}
}
}

View file

@ -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 {
}
}

View file

@ -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 {
}
}