mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-10 18:21:20 +00:00
memory clearing fixed
This commit is contained in:
parent
2415db0ff7
commit
221815e724
10 changed files with 88 additions and 15 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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}\"";
|
||||
|
||||
|
|
|
|||
10
source/Indy.IL2CPU.Assembler.X86/CLD.cs
Normal file
10
source/Indy.IL2CPU.Assembler.X86/CLD.cs
Normal 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 {
|
||||
}
|
||||
}
|
||||
|
|
@ -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" />
|
||||
|
|
|
|||
15
source/Indy.IL2CPU.Assembler.X86/JumpNotCary.cs
Normal file
15
source/Indy.IL2CPU.Assembler.X86/JumpNotCary.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ namespace Indy.IL2CPU.Assembler.X86 {
|
|||
// Destination = aDestination;
|
||||
}
|
||||
//public override string ToString() {
|
||||
// return "rep stos " + Destinati;
|
||||
// return "rep stosddword ";
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
source/Indy.IL2CPU.Assembler.X86/Stosb.cs
Normal file
10
source/Indy.IL2CPU.Assembler.X86/Stosb.cs
Normal 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 {
|
||||
}
|
||||
}
|
||||
10
source/Indy.IL2CPU.Assembler.X86/Stosw.cs
Normal file
10
source/Indy.IL2CPU.Assembler.X86/Stosw.cs
Normal 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 {
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue