Added a test kernel for boxing.

Moved Char Plug to Cosmos.System.Plugs
Added FAT writing. (Doesn't work yet.)
This commit is contained in:
Charles Betros 2015-07-24 17:52:44 -05:00
parent 67f492297f
commit 2e4e0dd370
25 changed files with 653 additions and 252 deletions

View file

@ -0,0 +1,36 @@
using System;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Package Name")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Company")]
[assembly: AssemblyProduct("Package Name")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: CLSCompliant(false)]
[assembly: NeutralResourcesLanguage("en-US")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F8889473-5866-4913-86AC-8072A1A2558C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BoxingTests</RootNamespace>
<AssemblyName>BoxingTests</AssemblyName>
<FileAlignment>512</FileAlignment>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Cosmos.Debug.Kernel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Users\Charles\AppData\Roaming\Cosmos User Kit\Kernel\Cosmos.Debug.Kernel.dll</HintPath>
</Reference>
<Reference Include="Cosmos.HAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Users\Charles\AppData\Roaming\Cosmos User Kit\Kernel\Cosmos.HAL.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Cosmos.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
<Reference Include="Cosmos.System, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
<Compile Include="Kernel.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cosmos.TestRunner.TestController\Cosmos.TestRunner.TestController.csproj">
<Project>{E6D3B644-C487-472D-A978-C1A82D0C099B}</Project>
<Name>Cosmos.TestRunner.TestController</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{444098bc-8f72-4030-a8c0-118d2dd93eb8}</ProjectGuid>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<Name>BoxingTestsBoot</Name>
<BinFormat>elf</BinFormat>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Profile>Bochs</Profile>
<!-- Looks like this was a mispelled attribute. Replaced by DebugEnabled below.
<DebugEnable>true</DebugEnable>
-->
<DebugEnabled>true</DebugEnabled>
<DebugMode>Source</DebugMode>
<TraceMode>User</TraceMode>
<EnableGDB>False</EnableGDB>
<StartCosmosGDB>false</StartCosmosGDB>
<VMWareEdition>Player</VMWareEdition>
<OutputPath>bin\Debug\</OutputPath>
<Name>BoxingTestsBoot</Name>
<Description>Use Bochs emulator to deploy and debug.</Description>
<Deployment>ISO</Deployment>
<Launch>Bochs</Launch>
<VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort>
<VMware_Name>BoxingTestsBoot</VMware_Name>
<VMware_Description>Use VMware Player or Workstation to deploy and debug.</VMware_Description>
<VMware_Deployment>ISO</VMware_Deployment>
<VMware_Launch>VMware</VMware_Launch>
<VMware_DebugEnabled>true</VMware_DebugEnabled>
<VMware_DebugMode>Source</VMware_DebugMode>
<VMware_VisualStudioDebugPort>Pipe: Cosmos\Serial</VMware_VisualStudioDebugPort>
<VMware_VMwareEdition>Player</VMware_VMwareEdition>
<VMware_OutputPath>bin\Debug\</VMware_OutputPath>
<VMware_EnableGDB>False</VMware_EnableGDB>
<VMware_StartCosmosGDB>false</VMware_StartCosmosGDB>
<Bochs_Name>BoxingTestsBoot</Bochs_Name>
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
<Bochs_Deployment>ISO</Bochs_Deployment>
<Bochs_Launch>Bochs</Bochs_Launch>
<Bochs_DebugEnabled>true</Bochs_DebugEnabled>
<Bochs_DebugMode>Source</Bochs_DebugMode>
<Bochs_VisualStudioDebugPort>Pipe: Cosmos\Serial</Bochs_VisualStudioDebugPort>
<Bochs_VMwareEdition>Player</Bochs_VMwareEdition>
<Bochs_OutputPath>bin\Debug\</Bochs_OutputPath>
<Bochs_EnableGDB>False</Bochs_EnableGDB>
<Bochs_StartCosmosGDB>false</Bochs_StartCosmosGDB>
<IntelEdison_Name>BoxingTestsBoot</IntelEdison_Name>
<IntelEdison_Description>Connect to Intel Edison device to deploy and debug.</IntelEdison_Description>
<IntelEdison_Deployment>BinaryImage</IntelEdison_Deployment>
<IntelEdison_Launch>IntelEdison</IntelEdison_Launch>
<IntelEdison_DebugEnabled>true</IntelEdison_DebugEnabled>
<IntelEdison_DebugMode>Source</IntelEdison_DebugMode>
<IntelEdison_VisualStudioDebugPort>Pipe: Cosmos\Serial</IntelEdison_VisualStudioDebugPort>
<IntelEdison_VMwareEdition>Player</IntelEdison_VMwareEdition>
<IntelEdison_OutputPath>bin\Debug\</IntelEdison_OutputPath>
<IntelEdison_EnableGDB>False</IntelEdison_EnableGDB>
<IntelEdison_StartCosmosGDB>false</IntelEdison_StartCosmosGDB>
<EnableBochsDebug>True</EnableBochsDebug>
<Bochs_EnableBochsDebug>True</Bochs_EnableBochsDebug>
</PropertyGroup>
<ItemGroup>
<Reference Include="Cosmos.Core.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983" />
<Reference Include="Cosmos.System.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983" />
<Reference Include="Cosmos.Debug.Kernel.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BoxingTests\BoxingTests.csproj">
<Name>BoxingTests</Name>
<Project>{f8889473-5866-4913-86ac-8072a1a2558c}</Project>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<!--<ItemGroup>
<Content Include="Cosmos.bxrc">
<SubType>Content</SubType>
</Content>
</ItemGroup>-->
<Import Project="$(MSBuildExtensionsPath)\Cosmos\Cosmos.targets" />
</Project>

View file

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Text;
using Cosmos.TestRunner;
using Sys = Cosmos.System;
namespace BoxingTests
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully.");
}
protected override void Run()
{
Assert.IsTrue(TestBoxingCharToString(), "Boxing char to string test failed.");
Assert.IsTrue(TestBoxingCharArrayToString(), "Boxing char[] to string test failed.");
TestController.Completed();
}
private bool TestBoxingCharToString()
{
try
{
char xC = 'c';
string xS = xC.ToString();
return (xS[0] == xC);
}
catch (Exception)
{
return false;
}
}
private bool TestBoxingCharArrayToString()
{
try
{
char[] xC = {'c'};
string xS = xC.ToString();
return (xS[0] == xC[0]);
}
catch (Exception)
{
return false;
}
}
}
}

View file

@ -117,6 +117,10 @@
<Project>{6128DEEB-D30F-4859-B60F-C36D5452F3E9}</Project>
<Name>IL2CPU</Name>
</ProjectReference>
<ProjectReference Include="..\BoxingTests\BoxingTests.csproj">
<Project>{f8889473-5866-4913-86ac-8072a1a2558c}</Project>
<Name>BoxingTests</Name>
</ProjectReference>
<ProjectReference Include="..\Cosmos.Compiler.Tests.Interfaces\Cosmos.Compiler.Tests.Interfaces.Kernel.csproj">
<Project>{bdc011be-6041-4a58-a6e7-0f592e78cb27}</Project>
<Name>Cosmos.Compiler.Tests.Interfaces.Kernel</Name>

View file

@ -24,7 +24,7 @@ namespace Cosmos.TestRunner.Core
engine.AddKernel(typeof(Cosmos.Compiler.Tests.SimpleWriteLine.Kernel.Kernel).Assembly.Location);
engine.AddKernel(typeof(SimpleStructsAndArraysTest.Kernel).Assembly.Location);
engine.AddKernel(typeof(VGACompilerCrash.Kernel).Assembly.Location);
engine.AddKernel(typeof(BoxingTests.Kernel).Assembly.Location);
// known bugs, therefor disabled for now:
// end of known bugs

View file

@ -21,7 +21,11 @@ namespace Cosmos.TestRunner.Core
protected override void OnExecuteKernelStart(string assemblyName)
{
var xParent = mCurrentNode.Peek();
XmlElement xParent = mDocument.DocumentElement;
if (mCurrentNode.Count > 0)
{
xParent = mCurrentNode.Peek();
}
var xItem = mDocument.CreateElement("Kernel");
xItem.Attributes.Append(NewXmlAttribute("AssemblyName", assemblyName));
xParent.AppendChild(xItem);
@ -42,7 +46,11 @@ namespace Cosmos.TestRunner.Core
protected override void OnLogDebugMessage(string message)
{
var xParent = mCurrentNode.Peek();
XmlElement xParent = mDocument.DocumentElement;
if (mCurrentNode.Count > 0)
{
xParent = mCurrentNode.Peek();
}
var xNode = xParent.SelectSingleNode("./DebugMessages");
if (xNode == null)
{
@ -56,7 +64,17 @@ namespace Cosmos.TestRunner.Core
protected override void OnLogMessage(string message)
{
var xParent = mCurrentNode.Peek();
XmlElement xParent = mDocument.DocumentElement;
if (mCurrentNode.Count > 0)
{
xParent = mCurrentNode.Peek();
}
var xNode = xParent.SelectSingleNode("./Messages");
if (xNode == null)
{
xNode = mDocument.CreateElement("Messages");
xParent.PrependChild(xNode);
}
var xItem = mDocument.CreateElement("Message");
xItem.InnerText = message;
xParent.AppendChild(xItem);
@ -64,7 +82,11 @@ namespace Cosmos.TestRunner.Core
protected override void OnLogError(string message)
{
var xParent = mCurrentNode.Peek();
XmlElement xParent = mDocument.DocumentElement;
if (mCurrentNode.Count > 0)
{
xParent = mCurrentNode.Peek();
}
var xItem = mDocument.CreateElement("Error");
xItem.AppendChild(mDocument.CreateCDataSection(message));
xParent.AppendChild(xItem);
@ -102,7 +124,11 @@ namespace Cosmos.TestRunner.Core
protected override void OnUnhandledException(Exception exception)
{
var xParent = mCurrentNode.Peek();
XmlElement xParent = mDocument.DocumentElement;
if (mCurrentNode.Count > 0)
{
xParent = mCurrentNode.Peek();
}
var xItem = mDocument.CreateElement("Exception");
xItem.AppendChild(mDocument.CreateCDataSection(exception.ToString()));
xParent.AppendChild(xItem);
@ -110,7 +136,11 @@ namespace Cosmos.TestRunner.Core
protected override void OnTaskStart(string taskName)
{
var xParent = mCurrentNode.Peek();
XmlElement xParent = mDocument.DocumentElement;
if (mCurrentNode.Count > 0)
{
xParent = mCurrentNode.Peek();
}
var xItem = mDocument.CreateElement("Task");
xItem.Attributes.Append(NewXmlAttribute("TaskName", taskName));
xParent.AppendChild(xItem);
@ -148,7 +178,11 @@ namespace Cosmos.TestRunner.Core
protected override void OnRunConfigurationStart(RunConfiguration configuration)
{
var xParent = mCurrentNode.Peek();
XmlElement xParent = mDocument.DocumentElement;
if (mCurrentNode.Count > 0)
{
xParent = mCurrentNode.Peek();
}
var xItem = mDocument.CreateElement("Configuration");
xItem.Attributes.Append(NewXmlAttribute("IsELF", configuration.IsELF.ToString()));
xItem.Attributes.Append(NewXmlAttribute("RunTarget", configuration.RunTarget.ToString()));

View file

@ -53,6 +53,10 @@
<Project>{3DEF0461-08AB-471A-8F03-A9C556652A0F}</Project>
<Name>Cosmos.System</Name>
</ProjectReference>
<ProjectReference Include="..\BoxingTests\BoxingTests.csproj">
<Project>{f8889473-5866-4913-86ac-8072a1a2558c}</Project>
<Name>BoxingTests</Name>
</ProjectReference>
<ProjectReference Include="..\Cosmos.Compiler.Tests.Interfaces\Cosmos.Compiler.Tests.Interfaces.Kernel.csproj">
<Project>{BDC011BE-6041-4A58-A6E7-0F592E78CB27}</Project>
<Name>Cosmos.Compiler.Tests.Interfaces.Kernel</Name>

View file

@ -23,6 +23,7 @@ namespace Cosmos.TestRunner.Console
xOutputXml,
new OutputHandlerConsole());
xEngine.RunTargets.Add(RunTargetEnum.Bochs);
xEngine.Execute();
global::System.Console.WriteLine("Do you want to save test run details?");

View file

@ -33,14 +33,14 @@ namespace SentinelKernel
return;
}
Console.WriteLine("Folder exists!");
xTest = Directory.Exists("0:\\test\\DirInTest");
if (!xTest)
{
Console.WriteLine("Subfolder doesn't exist!");
return;
}
Console.WriteLine("Subfolder exists as well!");
//Console.WriteLine("Folder exists!");
//xTest = Directory.Exists("0:\\test\\DirInTest");
//if (!xTest)
//{
// Console.WriteLine("Subfolder doesn't exist!");
// return;
//}
//Console.WriteLine("Subfolder exists as well!");
xTest = File.Exists(@"0:\KudzU.txt");
if (!xTest)
@ -48,23 +48,23 @@ namespace SentinelKernel
Console.WriteLine(@"\Kudzu.txt not found!");
return;
}
Console.WriteLine("Kudzu.txt found!");
xTest = File.Exists(@"0:\Test\DirInTest\Readme.txt");
if (!xTest)
{
Console.WriteLine(@"\Test\DirInTest\Readme.txt not found!");
return;
}
Console.WriteLine(@"Test\DirInTest\Readme.txt found!");
Console.Write("File contents of Kudzu.txt: ");
Console.WriteLine(File.ReadAllText(@"0:\Kudzu.txt"));
File.WriteAllText(@"0:\Kudzu.txt", "Test FAT write.");
Console.WriteLine(File.ReadAllText(@"0:\Kudzu.txt"));
Console.WriteLine(@"File contents of Test\DirInTest\Readme.txt: ");
Console.WriteLine(File.ReadAllText(@"0:\Test\DirInTest\Readme.txt"));
//xTest = File.Exists(@"0:\Test\DirInTest\Readme.txt");
//if (!xTest)
//{
// Console.WriteLine(@"\Test\DirInTest\Readme.txt not found!");
// return;
//}
//Console.WriteLine(@"Test\DirInTest\Readme.txt found!");
//Console.WriteLine(@"File contents of Test\DirInTest\Readme.txt: ");
//Console.WriteLine(File.ReadAllText(@"0:\Test\DirInTest\Readme.txt"));
}
catch (Exception e)
{
@ -74,7 +74,8 @@ namespace SentinelKernel
finally
{
while (true)
;
{
}
}
}
}

View file

@ -48,7 +48,7 @@
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
<Bochs_Deployment>ISO</Bochs_Deployment>
<Bochs_Launch>Bochs</Bochs_Launch>
<Bochs_DebugEnabled>True</Bochs_DebugEnabled>
<Bochs_DebugEnabled>False</Bochs_DebugEnabled>
<Bochs_StackCorruptionDetectionEnabled>True</Bochs_StackCorruptionDetectionEnabled>
<Bochs_DebugMode>Source</Bochs_DebugMode>
<Bochs_VisualStudioDebugPort>Pipe: Cosmos\Serial</Bochs_VisualStudioDebugPort>
@ -56,7 +56,7 @@
<Bochs_OutputPath>bin\Debug\</Bochs_OutputPath>
<Bochs_EnableGDB>False</Bochs_EnableGDB>
<Bochs_StartCosmosGDB>false</Bochs_StartCosmosGDB>
<Bochs_EnableBochsDebug>True</Bochs_EnableBochsDebug>
<Bochs_EnableBochsDebug>False</Bochs_EnableBochsDebug>
<VMware_EnableBochsDebug>True</VMware_EnableBochsDebug>
<TraceAssemblies>All</TraceAssemblies>
<VMware_TraceAssemblies>All</VMware_TraceAssemblies>

View file

@ -1,50 +0,0 @@
# configuration file generated by Bochs
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, gameport=1, iodebug=1
config_interface: win32config
display_library: win32
memory: host=256, guest=256
romimage: file="C:\Program Files (x86)\Bochs-2.6.8/BIOS-bochs-latest"
vgaromimage: file="C:\Program Files (x86)\Bochs-2.6.8/VGABIOS-lgpl-latest"
boot: cdrom
floppy_bootsig_check: disabled=0
# no floppya
# no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=cdrom, path="SentinelKernelBoot.iso", status=inserted, model="Generic 1234", biosdetect=auto
ata0-slave: type=none
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata1-master: type=disk, path="C:\Data\Sources\OpenSource\Cosmos\Build\VMWare\Workstation\Filesystem.vmdk", mode=vmware4, cylinders=0, heads=0, spt=0, model="Generic 1234", biosdetect=auto, translation=auto
ata1-slave: type=none
ata2: enabled=0
ata3: enabled=0
pci: enabled=1, chipset=i440fx
vga: extension=vbe, update_freq=5, realtime=1
cpu: count=1, ips=4000000, model=bx_generic, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0
cpuid: level=6, stepping=3, model=3, family=6, vendor_string="GenuineIntel", brand_string=" Intel(R) Pentium(R) 4 CPU "
cpuid: mmx=1, apic=xapic, simd=sse2, sse4a=0, misaligned_sse=0, sep=1, movbe=0, adx=0
cpuid: aes=0, sha=0, xsave=0, xsaveopt=0, x86_64=1, 1g_pages=0, pcid=0, fsgsbase=0
cpuid: smep=0, smap=0, mwait=1, vmx=1
print_timestamps: enabled=0
debugger_log: -
magic_break: enabled=0
port_e9_hack: enabled=0
private_colormap: enabled=0
clock: sync=none, time0=local, rtc_sync=0
# no cmosimage
# no loader
log: -
logprefix: %t%e%d
debug: action=ignore, cpu0=report
info: action=report
error: action=report
panic: action=ask
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none
mouse: type=ps2, enabled=0, toggle=ctrl+mbutton
sound: waveoutdrv=win, waveout=none, waveindrv=win, wavein=none, midioutdrv=win, midiout=none
speaker: enabled=1, mode=sound
parport1: enabled=1, file=none
parport2: enabled=0
com1: enabled=1, mode=null
com2: enabled=0
com3: enabled=0
com4: enabled=0

View file

@ -179,6 +179,12 @@ namespace SentinelKernel.System.FileSystem.FAT
mDevice.ReadBlock(xSector, SectorsPerCluster, aData);
}
public void WriteCluster(UInt64 aCluster, byte[] aData)
{
UInt64 xSector = DataSector + ((aCluster - 2) * SectorsPerCluster);
mDevice.WriteBlock(xSector, SectorsPerCluster, aData);
}
public void GetFatTableSector(UInt64 aClusterNum, out UInt32 oSector, out UInt32 oOffset)
{
UInt64 xOffset = 0;

View file

@ -44,7 +44,7 @@ namespace SentinelKernel.System.FileSystem.FAT
public override bool CanWrite
{
get { return false; }
get { return true; }
}
public override long Length
@ -71,10 +71,10 @@ namespace SentinelKernel.System.FileSystem.FAT
public override int Read(byte[] aBuffer, int aOffset, int aCount)
{
return Read(aBuffer, (Int64)aOffset, (Int64)aCount);
return Read(aBuffer, aOffset, aCount);
}
public int Read(byte[] aBuffer, Int64 aOffset, Int64 aCount)
protected int Read(byte[] aBuffer, Int64 aOffset, Int64 aCount)
{
if (aCount < 0)
{
@ -131,7 +131,6 @@ namespace SentinelKernel.System.FileSystem.FAT
aOffset += xReadSize;
xCount -= (ulong)xReadSize;
xCount = 0;
}
mPosition += (ulong)aOffset;
@ -150,17 +149,80 @@ namespace SentinelKernel.System.FileSystem.FAT
public override void SetLength(long value)
{
throw new NotImplementedException();
var xOldClusterTotal = Length/mFS.BytesPerCluster;
if (Length%mFS.BytesPerCluster != 0)
{
xOldClusterTotal++;
}
var xNewClusterTotal = value/mFS.BytesPerCluster;
if (value%mFS.BytesPerCluster != 0)
{
xNewClusterTotal++;
}
if (xNewClusterTotal != xOldClusterTotal)
{
throw new NotImplementedException("Setting the stream length to a size that requires alllcating new clusters is not currently implemented.");
}
//mFile.Size = value;
}
public override void Write(byte[] aBuffer, int aOffset, int aCount)
{
Write(aBuffer, (long)aOffset, (long)aCount);
Write(aBuffer, aOffset, aCount);
}
public void Write(byte[] buffer, long offset, long count)
protected void Write(byte[] aBuffer, long aOffset, long aCount)
{
throw new NotImplementedException();
if (aCount < 0)
{
throw new ArgumentOutOfRangeException("aCount");
}
if (aOffset < 0)
{
throw new ArgumentOutOfRangeException("aOffset");
}
if (aBuffer == null || aBuffer.Length - aOffset < aCount)
{
throw new ArgumentException("Invalid offset length!");
}
ulong xCount = (ulong)aCount;
var xCluster = mFS.NewClusterArray();
UInt32 xClusterSize = mFS.BytesPerCluster;
long xTotalLength = (long) (mPosition + xCount);
if (xTotalLength > Length)
{
SetLength(xTotalLength);
}
while (xCount > 0)
{
long xWriteSize;
UInt64 xClusterIdx = mPosition / xClusterSize;
UInt64 xPosInCluster = mPosition % xClusterSize;
if (xPosInCluster + xCount > xClusterSize)
{
xWriteSize = (long)(xClusterSize - xPosInCluster - 1);
}
else
{
xWriteSize = (long)xCount;
}
Array.Copy(aBuffer, (long)xPosInCluster, xCluster, aOffset, xWriteSize);
mFS.WriteCluster((ulong)mFatTable[(int)xClusterIdx], xCluster);
aOffset += xWriteSize;
xCount -= (ulong)xWriteSize;
}
mPosition += (ulong)aOffset;
}
}
}

View file

@ -20,7 +20,7 @@ namespace SentinelKernel.System.FileSystem.VFS
public abstract List<System.FileSystem.Listing.Directory> GetVolumes();
public static char DirectorySeparatorChar { get { return '\\'; } }
public static char DirectorySeparatorChar => '\\';
public static char AltDirectorySeparatorChar { get { return '/'; } }

View file

@ -134,7 +134,7 @@ namespace SentinelKernel.System.FileSystem.VFS
#endregion
public static Listing.File TryGetFile(string aPath)
public static Listing.File TryGetFile(string aPath)
{
if (string.IsNullOrEmpty(aPath))
{
@ -291,7 +291,7 @@ namespace SentinelKernel.System.FileSystem.VFS
try
{
FatHelpers.Debug("DirectoryExists. Path = '" + aPath + "'");
string xDir = aPath + VFSBase.DirectorySeparatorChar;
string xDir = string.Concat(aPath + VFSBase.DirectorySeparatorChar);
//xDir = Path.GetDirectoryName(xDir);
return (VFSManager.GetDirectory(xDir) != null);
}

View file

@ -14,11 +14,9 @@ namespace SentinelKernel.System.Plugs.System.IO
{
public static bool Exists(string aFile)
{
return FileSystem.VFS.VFSManager.FileExists(aFile);
return VFSManager.FileExists(aFile);
}
public static string ReadAllText(string aFile)
{
using (var xFS = new FileStream(aFile, FileMode.Open))
@ -34,11 +32,13 @@ namespace SentinelKernel.System.Plugs.System.IO
}
}
// if (!File.Exists(aFile))
// return "Could not find file " + aFile;
// //throw new FileNotFoundException("Could not find file " + aFile);
// return VFSManager.ReadFileAsString(aFile);
//}
public static void WriteAllText(string aFile, string aText)
{
using (var xFS = new FileStream(aFile, FileMode.Create))
{
var xBuff = aText.GetUtf8Bytes(0, (uint) aText.Length);
xFS.Write(xBuff, 0, xBuff.Length);
}
}
}
}

View file

@ -8,18 +8,16 @@ using SentinelKernel.System.FileSystem.VFS;
namespace SentinelKernel.System.Plugs.System.IO
{
[Plug(Target = typeof(IO::FileStream))]
[PlugField(FieldId = "$$InnerStream$$", FieldType = typeof(IO::Stream))]
[Plug(Target = typeof (IO::FileStream))]
[PlugField(FieldId = "$$InnerStream$$", FieldType = typeof (IO::Stream))]
public class FileStreamImpl
{
// This plug basically forwards all calls to the $$InnerStream$$ stream, which is supplied by the file system.
// public static unsafe void Ctor(String aThis, [FieldAccess(Name = "$$Storage$$")]ref Char[] aStorage, Char[] aChars, int aStartIndex, int aLength,
// public static unsafe void Ctor(String aThis, [FieldAccess(Name = "$$Storage$$")]ref Char[] aStorage, Char[] aChars, int aStartIndex, int aLength,
public static void Ctor(IO::FileStream aThis, string aPathname, IO::FileMode aMode, [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
public static void Ctor(IO::FileStream aThis, string aPathname, IO::FileMode aMode,
[FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
{
innerStream = VFSManager.GetFileStream(aPathname);
}
@ -29,19 +27,28 @@ namespace SentinelKernel.System.Plugs.System.IO
// plug cctor as it (indirectly) uses Thread.MemoryBarrier()
}
public static int Read(IO::FileStream aThis, byte[] aBuffer, int aOffset, int aCount, [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
public static int Read(IO::FileStream aThis, byte[] aBuffer, int aOffset, int aCount,
[FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
{
return innerStream.Read(aBuffer, aOffset, aCount);
}
public static long get_Length(IO::FileStream aThis, [FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
public static void Write(IO::FileStream aThis, byte[] aBuffer, int aOffset, int aCount,
[FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
{
innerStream.Write(aBuffer, aOffset, aCount);
}
public static long get_Length(IO::FileStream aThis,
[FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
{
return innerStream.Length;
}
public static void SetLength(IO::FileStream aThis, long value)
public static void SetLength(IO::FileStream aThis, long aLength,
[FieldAccess(Name = "$$InnerStream$$")] ref IO::Stream innerStream)
{
throw new NotImplementedException();
innerStream.SetLength(aLength);
}
public static void Dispose(IO::FileStream aThis, bool disposing)

View file

@ -50,6 +50,17 @@ namespace Cosmos.Common.Extensions {
return new string(xChars);
}
static public byte[] GetUtf8Bytes(this string n, UInt32 aStart, UInt32 aCharCount)
{
// TODO: This method handles ASCII only currently, no unicode.
var xBytes = new byte[aCharCount];
for (int i = 0; i < aCharCount; i++)
{
xBytes[i] = (byte)n[(int) ((aStart) + i)];
}
return xBytes;
}
static public string GetUtf16String(this byte[] n, UInt32 aStart, UInt32 aCharCount) {
//TODO: This routine only handles ASCII. It does not handle unicode yet.
var xChars = new char[aCharCount];

View file

@ -110,7 +110,6 @@
<Compile Include="CustomImplementation\System\ArrayImplRefs.cs" />
<Compile Include="CustomImplementation\System\BooleanImpl.cs" />
<Compile Include="CustomImplementation\System\ByteImpl.cs" />
<Compile Include="CustomImplementation\System\CharImpl.cs" />
<Compile Include="CustomImplementation\System\DelegateHelper.cs" />
<Compile Include="CustomImplementation\System\DelegateImpl.cs" />
<Compile Include="CustomImplementation\System\DoubleImpl.cs" />

View file

@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.IL2CPU.Plugs;
namespace Cosmos.IL2CPU.IL.CustomImplementations.System {
[Plug(Target = typeof(char))]
public static class CharImpl {
public static void Cctor() {
//
}
//[PlugMethod(Signature = "System_String___System_Char_ToString____")]
public static string ToString(ref char aThis) {
char[] xResult = new char[1];
xResult[0] = aThis;
return new String(xResult);
} // System_String__System_Char_ToString__
public static char ToUpper(char aThis) {
// todo: properly implement Char.ToUpper()
return aThis;
}
public static bool IsWhiteSpace(char aChar) {
return aChar == ' ' || aChar == '\t';
}
}
}

View file

@ -71,6 +71,7 @@
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="System\CharImpl.cs" />
<Compile Include="System\DictionaryImpl.cs" />
<Compile Include="System\IO\FileStreamImpl.cs" />
<Compile Include="System\IO\StreamReaderImpl.cs" />

View file

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cosmos.IL2CPU.Plugs;
namespace Cosmos.System.Plugs.System
{
[Plug(Target = typeof(char))]
public static class CharImpl
{
public static void Cctor()
{
//
}
public static string ToString(ref char aThis)
{
char[] xResult = new char[1];
xResult[0] = aThis;
return new string(xResult);
}
public static char ToUpper(char aThis)
{
// todo: properly implement Char.ToUpper()
return aThis;
}
public static bool IsWhiteSpace(char aChar)
{
return aChar == ' ' || aChar == '\t';
}
}
}

View file

@ -235,6 +235,10 @@ Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "VGACompilerCrashBoot", "..\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.TestRunner.UI", "..\Tests\Cosmos.TestRunner.UI\Cosmos.TestRunner.UI.csproj", "{0B20C26F-CA92-4D88-8211-EC7B0A261337}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BoxingTests", "..\Tests\BoxingTests\BoxingTests.csproj", "{F8889473-5866-4913-86AC-8072A1A2558C}"
EndProject
Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "BoxingTestsBoot", "..\Tests\BoxingTests\BoxingTestsBoot.Cosmos", "{444098BC-8F72-4030-A8C0-118D2DD93EB8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1192,6 +1196,38 @@ Global
{0B20C26F-CA92-4D88-8211-EC7B0A261337}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0B20C26F-CA92-4D88-8211-EC7B0A261337}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0B20C26F-CA92-4D88-8211-EC7B0A261337}.Release|x86.ActiveCfg = Release|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Debug|Itanium.ActiveCfg = Debug|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Debug|Itanium.Build.0 = Debug|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Debug|x86.ActiveCfg = Debug|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Debug|x86.Build.0 = Debug|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Release|Any CPU.Build.0 = Release|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Release|Itanium.ActiveCfg = Release|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Release|Itanium.Build.0 = Release|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Release|x86.ActiveCfg = Release|Any CPU
{F8889473-5866-4913-86AC-8072A1A2558C}.Release|x86.Build.0 = Release|Any CPU
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Debug|Any CPU.ActiveCfg = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Debug|Any CPU.Build.0 = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Debug|Itanium.ActiveCfg = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Debug|Itanium.Build.0 = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Debug|Mixed Platforms.Build.0 = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Debug|x86.ActiveCfg = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Debug|x86.Build.0 = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Release|Any CPU.ActiveCfg = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Release|Any CPU.Build.0 = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Release|Itanium.ActiveCfg = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Release|Itanium.Build.0 = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Release|Mixed Platforms.ActiveCfg = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Release|Mixed Platforms.Build.0 = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Release|x86.ActiveCfg = Debug|x86
{444098BC-8F72-4030-A8C0-118D2DD93EB8}.Release|x86.Build.0 = Debug|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1284,5 +1320,7 @@ Global
{21915A7E-CC84-4836-8B87-857B6149D496} = {F104F6BC-EF8E-4408-A786-D570D7565231}
{78AC2B12-8185-4033-80F0-DA5BF874BE5E} = {F104F6BC-EF8E-4408-A786-D570D7565231}
{0B20C26F-CA92-4D88-8211-EC7B0A261337} = {79173AE7-4596-4D33-866F-6F94A2314BE8}
{F8889473-5866-4913-86AC-8072A1A2558C} = {F104F6BC-EF8E-4408-A786-D570D7565231}
{444098BC-8F72-4030-A8C0-118D2DD93EB8} = {F104F6BC-EF8E-4408-A786-D570D7565231}
EndGlobalSection
EndGlobal

View file

@ -1,121 +1,161 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.html.cs" Inherits="XSharp_index" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<h3>
X#<p>
X# compiles C# code into assembly, but does it as it runs. This allows the use
of intellisense, and modification of the output using C#.</p>
<li>One of the goals of Cosmos is the need to write very little assembly, so only
debug stub, compiler users, etc need assembly. Too much work on X# may not be
worth the resources required.</li>
<h3>
Consts</h3>
<p>
ref with #. else user would need to use @, and if not woudl get [value] instead.
ie consts have direct ref as default while fields have indirect as default. Also
treat consts diff since they can only be read from and not assigned, and at
parse time we dont know if a label is const, var or other.</p>
<p>
all consts are group based. Need provision for globals in future. Consts cannot
be local.</p>
<h3>
Method</h3>
<p>
name()</p>
<li>
X# compiles C# code into assembly, but does it as it runs. This allows the use
of intellisense, and modification of the output using C#.
</p>
<li>
One of the goals of Cosmos is the need to write very little assembly, so only
debug stub, compiler users, etc need assembly. Too much work on X# may not be
worth the resources required.
</li>
<h3>
Usage</h3>
<p>
look in tokenpatterns.cs for more</p>
<h3>
Labels</h3>
<p>
..Global</p>
<p>
.Group</p>
<p>
Local</p>
<p>
Think of it like a directory path, .. and . are up.</p>
<h3>
Checkpoint &#39;text&#39;</h3>
<p>
&nbsp;</p>
<h3>
if reg = x goto label</h3>
<p>
=<br />
!=<br />
&gt;<br />
&gt;=<br />
&lt;<br />
&lt;=</p>
<h3>
Register Arithmetic</h3>
<p>
EBP = EBP + 32;<br />
This is not possible because C# operator overloading does not look at return
type but only the operand types. That is C# sees Register + int. If we supported
the previous example, then X# could not support:<br />
EAX = Memory[EBP + 4];<br />
In short, C# sees these two as the same and so X# can only support one. Because
the memory addressing is used more frequently than adding a constant to a
register, X# supports it.<br />
To add a constant to a register use:<br />
EBP.Add(32);</p>
<h3>
Register-- / Register++</h3>
<p>
Valid and usable. Correspond to Inc and Dec.</p>
<h3>
Register Shifting</h3>
<p>
Example:<br />
EAX &lt;&lt; 2</p>
<h3>
Rotate</h3>
Consts
</h3>
<p>
&nbsp;~ &quot;infinite&quot; shift because it loops </p>
<h3>
Register Methods</h3>
<ul>
<li>Add</li>
<li>Sub</li>
<li>Compare</li>
<li>Test</li>
</ul>
<h3>
Register = int</h3>
<p>
Example:<br />
EAX = $40<br />
EAX = 64</p>
<h3>
Register = Register</h3>
<p>
Example:<br />
EAX = EBP</p>
<h3>
Register = Memory[Address];<br />
Register = Memory[Address + int];</h3>
<p>
Address can be a string label. i.e. EAX = Memory[&quot;Data1&quot;]</p>
<h3>
Register = Port[x]<br />
Register = Port[EAX]</h3>
<p>
public static implicit operator RegisterEAX(Cosmos.Assembler.ElementReference aReference) {
Instance.Move(aReference); return Instance; }
</p>
<h3>
Register = Label</h3>
<p>
Example:<br />
EAX = AddressOf(&quot;Labelname&quot;);</p>
ref with #. else user would need to use @, and if not woudl get [value] instead.
ie consts have direct ref as default while fields have indirect as default. Also
treat consts diff since they can only be read from and not assigned, and at
parse time we dont know if a label is const, var or other.
</p>
<p>
all consts are group based. Need provision for globals in future. Consts cannot
be local.
</p>
<h3>
Method
</h3>
<p>
name()
</p>
<li>
<h3>
Usage
</h3>
<p>
look in tokenpatterns.cs for more
</p>
<h3>
Labels
</h3>
<p>
..Global
</p>
<p>
.Group
</p>
<p>
Local
</p>
<p>
Think of it like a directory path, .. and . are up.
</p>
<h3>
Checkpoint &#39;text&#39;
</h3>
<p>
&nbsp;
</p>
<h3>
if reg = x goto label
</h3>
<p>
=<br />
!=<br />
&gt;<br />
&gt;=<br />
&lt;<br />
&lt;=
</p>
<h3>
Register Arithmetic
</h3>
<p>
EBP = EBP + 32;<br />
This is not possible because C# operator overloading does not look at return
type but only the operand types. That is C# sees Register + int. If we supported
the previous example, then X# could not support:<br />
EAX = Memory[EBP + 4];<br />
In short, C# sees these two as the same and so X# can only support one. Because
the memory addressing is used more frequently than adding a constant to a
register, X# supports it.<br />
To add a constant to a register use:<br />
EBP.Add(32);
</p>
<h3>
Register-- / Register++
</h3>
<p>
Valid and usable. Correspond to Inc and Dec.
</p>
<h3>
Register Shifting
</h3>
<p>
Example:<br />
EAX &lt;&lt; 2
</p>
<h3>
Rotate
</h3>
<p>
&nbsp;~ &quot;infinite&quot; shift because it loops
</p>
<h3>
Register Methods
</h3>
<ul>
<li>Add</li>
<li>Sub</li>
<li>Compare</li>
<li>Test</li>
</ul>
<h3>
Register = int
</h3>
<p>
Example:<br />
EAX = $40<br />
EAX = 64
</p>
<h3>
Register = Register
</h3>
<p>
Example:<br />
EAX = EBP
</p>
<h3>
Register = Memory[Address];<br />
Register = Memory[Address + int];
</h3>
<p>
Address can be a string label. i.e. EAX = Memory[&quot;Data1&quot;]
</p>
<h3>
Register = Port[x]<br />
Register = Port[EAX]
</h3>
<p>
public static implicit operator RegisterEAX(Cosmos.Assembler.ElementReference aReference) {
Instance.Move(aReference); return Instance; }
</p>
<h3>
Register = Label
</h3>
<p>
Example:<br />
EAX = AddressOf(&quot;Labelname&quot;);
</p>
</li>
</h3>
</body>
</html>