mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-11 18:51:41 +00:00
Progress on memory. Fix ldelem_ref.
This commit is contained in:
parent
bae772237f
commit
f3bb974712
6 changed files with 35 additions and 49 deletions
|
|
@ -344,8 +344,8 @@ namespace Cosmos.HAL.BlockDevice
|
|||
|
||||
public override void WriteBlock(UInt64 aBlockNo, UInt64 aBlockCount, byte[] aData)
|
||||
{
|
||||
CheckDataSize(aData, aBlockCount);
|
||||
SelectSector(aBlockNo, aBlockCount);
|
||||
CheckDataSize(aData, aBlockCount);
|
||||
SelectSector(aBlockNo, aBlockCount);
|
||||
SendCmd(LBA48Bit ? Cmd.WritePioExt : Cmd.WritePio);
|
||||
|
||||
UInt16 xValue;
|
||||
|
|
|
|||
|
|
@ -42,32 +42,13 @@ namespace Cosmos.HAL.BlockDevice
|
|||
|
||||
protected void CheckDataSize(byte[] aData, UInt64 aBlockCount)
|
||||
{
|
||||
aData = new byte[1024];
|
||||
var xActualLength = aData.Length;
|
||||
var xExpectedDataSize = aBlockCount * mBlockSize;
|
||||
Debugger.DoSend("Expected data size:");
|
||||
Debugger.DoSendNumber(xExpectedDataSize);
|
||||
Debugger.DoSend("Actual data size:");
|
||||
Debugger.DoSendNumber(xActualLength);
|
||||
Debugger.DoSend("Actual data size:");
|
||||
Debugger.DoSendNumber(xActualLength);
|
||||
Debugger.DoSend("Actual data size:");
|
||||
Debugger.DoSendNumber(xActualLength);
|
||||
Debugger.DoSend("Actual data size:");
|
||||
Debugger.DoSendNumber(aData.Length);
|
||||
Debugger.DoSend("Expected data size:");
|
||||
Debugger.DoSendNumber(xExpectedDataSize);
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
;
|
||||
;
|
||||
;
|
||||
}
|
||||
while (true)
|
||||
;
|
||||
//var xBlockSize = mBlockSize;
|
||||
//var xDataLength = aData.Length;
|
||||
//var xDataSize = aBlockCount * mBlockSize;
|
||||
|
||||
if ((ulong)aData.Length != aBlockCount * mBlockSize)
|
||||
{
|
||||
throw new Exception("Invalid data size.");
|
||||
|
|
|
|||
|
|
@ -20,14 +20,16 @@ namespace Cosmos.HAL.BlockDevice
|
|||
|
||||
public override void ReadBlock(UInt64 aBlockNo, UInt64 aBlockCount, byte[] aData)
|
||||
{
|
||||
UInt64 xHostBlockNo = mStartingSector + aBlockNo;
|
||||
CheckDataSize(aData, aBlockCount);
|
||||
UInt64 xHostBlockNo = mStartingSector + aBlockNo;
|
||||
CheckBlockNo(xHostBlockNo, aBlockCount);
|
||||
mHost.ReadBlock(xHostBlockNo, aBlockCount, aData);
|
||||
}
|
||||
|
||||
public override void WriteBlock(UInt64 aBlockNo, UInt64 aBlockCount, byte[] aData)
|
||||
{
|
||||
UInt64 xHostBlockNo = mStartingSector + aBlockNo;
|
||||
CheckDataSize(aData, aBlockCount);
|
||||
UInt64 xHostBlockNo = mStartingSector + aBlockNo;
|
||||
CheckBlockNo(xHostBlockNo, aBlockCount);
|
||||
mHost.WriteBlock(xHostBlockNo, aBlockCount, aData);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,19 +85,22 @@ namespace Cosmos.HAL
|
|||
}
|
||||
|
||||
// TODO Change this to foreach when foreach is supported
|
||||
Ata.AtaDebugger.Send("Number of MBR partitions found: " + xMBR.Partitions.Count);
|
||||
Ata.AtaDebugger.Send("Number of MBR partitions found:");
|
||||
Ata.AtaDebugger.SendNumber(xMBR.Partitions.Count);
|
||||
for (int i = 0; i < xMBR.Partitions.Count; i++)
|
||||
{
|
||||
var xPart = xMBR.Partitions[i];
|
||||
if (xPart == null)
|
||||
{
|
||||
Console.WriteLine("Null partition found at idx " + i);
|
||||
Console.WriteLine("Null partition found at idx:");
|
||||
Console.WriteLine(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
var xPartDevice = new Partition(xATA, xPart.StartSector, xPart.SectorCount);
|
||||
BlockDevice.BlockDevice.Devices.Add(xPartDevice);
|
||||
Console.WriteLine("Found partition at idx " + i);
|
||||
Console.WriteLine("Found partition at idx");
|
||||
Console.WriteLine(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -917,7 +917,7 @@ namespace Cosmos.IL2CPU
|
|||
XS.DataMemberBytes(xTheName + "_Contents", xData);
|
||||
XS.DataMember(xTheName, 1, "dd", xTheName + "_Contents");
|
||||
#if VMT_DEBUG
|
||||
using (var xVmtDebugOutput = XmlWriter.Create(@"c:\data\vmt_debug.xml"))
|
||||
using (var xVmtDebugOutput = XmlWriter.Create(@"vmt_debug.xml"))
|
||||
{
|
||||
xVmtDebugOutput.WriteStartDocument();
|
||||
xVmtDebugOutput.WriteStartElement("VMT");
|
||||
|
|
|
|||
|
|
@ -1,42 +1,42 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using CPUx86 = Cosmos.Assembler.x86;
|
||||
using Cosmos.Assembler;
|
||||
using Cosmos.IL2CPU.ILOpCodes;
|
||||
using Cosmos.IL2CPU.Plugs.System;
|
||||
using XSharp.Compiler;
|
||||
using static XSharp.Compiler.XSRegisters;
|
||||
|
||||
namespace Cosmos.IL2CPU.X86.IL
|
||||
{
|
||||
[Cosmos.IL2CPU.OpCode(ILOpCode.Code.Ldelem_Ref)]
|
||||
[OpCode(ILOpCode.Code.Ldelem_Ref)]
|
||||
public class Ldelem_Ref : ILOp
|
||||
{
|
||||
public Ldelem_Ref(Cosmos.Assembler.Assembler aAsmblr)
|
||||
public Ldelem_Ref(Assembler.Assembler aAsmblr)
|
||||
: base(aAsmblr)
|
||||
{
|
||||
}
|
||||
|
||||
public static void Assemble(Cosmos.Assembler.Assembler aAssembler, uint aElementSize, bool isSigned, bool debugEnabled)
|
||||
public static void Assemble(Assembler.Assembler aAssembler, uint aElementSize, bool isSigned, bool debugEnabled)
|
||||
{
|
||||
// stack - 1: array
|
||||
// stack - 0: index
|
||||
DoNullReferenceCheck(aAssembler, debugEnabled, 8);
|
||||
|
||||
XS.Pop(XSRegisters.EAX); // index
|
||||
XS.Set(XSRegisters.EDX, aElementSize);
|
||||
XS.Add(XSRegisters.ESP, 4);
|
||||
XS.Multiply(XSRegisters.EDX);
|
||||
|
||||
XS.Add(XSRegisters.EAX, (ObjectImpl.FieldDataOffset + 4));
|
||||
// calculate element offset into array memory (including header)
|
||||
XS.Pop(EAX);
|
||||
XS.Set(EDX, aElementSize);
|
||||
XS.Multiply(EDX);
|
||||
XS.Add(EAX, ObjectImpl.FieldDataOffset + 4);
|
||||
|
||||
if (aElementSize > 4)
|
||||
{
|
||||
// we start copying the last bytes
|
||||
XS.Add(XSRegisters.EAX, aElementSize - 4);
|
||||
XS.Add(EAX, aElementSize - 4);
|
||||
}
|
||||
|
||||
// pop the array
|
||||
XS.Pop(XSRegisters.EDX);
|
||||
|
||||
XS.Add(XSRegisters.EDX, XSRegisters.EAX);
|
||||
// pop the array now
|
||||
XS.Add(ESP, 4);
|
||||
XS.Pop(EDX);
|
||||
|
||||
XS.Add(EDX, EAX);
|
||||
|
||||
var xSizeLeft = aElementSize;
|
||||
while (xSizeLeft > 0)
|
||||
|
|
@ -58,7 +58,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
{
|
||||
new CPUx86.MoveZeroExtend { DestinationReg = CPUx86.RegistersEnum.ECX, Size = 8, SourceReg = CPUx86.RegistersEnum.EDX, SourceIsIndirect = true };
|
||||
}
|
||||
XS.Push(XSRegisters.ECX);
|
||||
XS.Push(ECX);
|
||||
break;
|
||||
case 2:
|
||||
if (isSigned)
|
||||
|
|
@ -69,12 +69,12 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
{
|
||||
new CPUx86.MoveZeroExtend { DestinationReg = CPUx86.RegistersEnum.ECX, Size = 16, SourceReg = CPUx86.RegistersEnum.EDX, SourceIsIndirect = true };
|
||||
}
|
||||
XS.Push(XSRegisters.ECX);
|
||||
XS.Push(ECX);
|
||||
break;
|
||||
case 4:
|
||||
// copy a full dword
|
||||
XS.Push(XSRegisters.EDX, isIndirect: true);
|
||||
XS.Sub(XSRegisters.EDX, 4); // move to previous 4 bytes
|
||||
XS.Push(EDX, isIndirect: true);
|
||||
XS.Sub(EDX, 4); // move to previous 4 bytes
|
||||
break;
|
||||
//case 8:
|
||||
// new CPUx86.Push {DestinationReg = CPUx86.Registers.EDX, DestinationDisplacement = 4, DestinationIsIndirect = true};
|
||||
|
|
|
|||
Loading…
Reference in a new issue