LabelName: Was removing underscores from method namesfor readability. Caused bug with Buffer.__Memcpy where Buffer.MemCpy and Buffer._Memcpy were also used labels.

PlugManager: bug in my design fixed.
FatFileSystem: completed the todo that said trailing periods should be ignored.
Buffer: Added __Memcpy plug so that String.Trim method compiles so that FAT code will compile.
This commit is contained in:
EdwardNutting_cp 2014-02-04 16:27:16 +00:00
parent 658a629be3
commit cbd1b81ffb
6 changed files with 162 additions and 6 deletions

View file

@ -242,8 +242,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugCompiler", "..\source2
{89868CAD-AAFC-45F1-81B3-C323F87D5742} = {89868CAD-AAFC-45F1-81B3-C323F87D5742}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugs", "Plugs", "{AB9170C5-2959-43BE-B7F1-BA63CFFBC967}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ed Nutting", "Ed Nutting", "{2BFDA1D7-02C3-45A7-9FC1-E79D2C737DE8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdNuttingsTest", "..\source2\Users\EdNutting\EdNuttingsTest\EdNuttingsTest.csproj", "{05FC6729-A0E3-48A4-AC5C-A0126F1972F4}"

View file

@ -36,7 +36,7 @@ namespace Cosmos.Assembler {
public static string Get(string aMethodLabel, int aIlPos) {
return aMethodLabel + ".IL_" + aIlPos.ToString("X4");
}
public static System.Text.RegularExpressions.Regex IllegalCharsReplace = new System.Text.RegularExpressions.Regex(@"[&.,+$<>{}\-\`\\'/\\ \(\)\[\]\*!=_]", System.Text.RegularExpressions.RegexOptions.Compiled);
public static System.Text.RegularExpressions.Regex IllegalCharsReplace = new System.Text.RegularExpressions.Regex(@"[&.,+$<>{}\-\`\\'/\\ \(\)\[\]\*!=]", System.Text.RegularExpressions.RegexOptions.Compiled);
public static string Final(string xName) {
//var xSB = new StringBuilder(xName);

View file

@ -235,10 +235,10 @@ namespace Cosmos.IL2CPU
}
OK = true;
// Exact params match - there should never be "null" types for statics since none should be pointers!
// Exact params match excl. pointers - there could be "null" types for statics since some could be pointers
for (int i = 0; i < posMethParamTypes.Length; i++)
{
if (!posMethParamTypes[i].Equals(xParamTypes[i]))
if ((posMethParamTypes[i] == null && xParamTypes[i] == null) || !posMethParamTypes[i].Equals(xParamTypes[i]))
{
OK = false;
break;

View file

@ -8,6 +8,11 @@ namespace Cosmos.IL2CPU.X86.Plugs.CustomImplementations.System {
[Plug(Target = typeof(global::System.Buffer))]
public class Buffer {
public static unsafe void __Memcpy(byte* src, byte* dest, int count)
{
global::System.Buffer.BlockCopy((Array)(object)*src, 0, (Array)(object)*dest, 0, count);
}
[PlugMethod(Assembler = typeof(Assemblers.Buffer_BlockCopy))]
public static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count) {
}

View file

@ -231,8 +231,24 @@ namespace Cosmos.System.Filesystem.FAT {
// Leading and trailing spaces are to be ignored according to spec.
// Many programs (including Windows) pad trailing spaces although it
// it is not required for long names.
// TODO: As per spec, ignore trailing periods
// As per spec, ignore trailing periods
xName = xLongName.Trim();
//If there are trailing periods
int nameIndex = xName.Length - 1;
if (xName[nameIndex] == '.')
{
//Search backwards till we find the first non-period character
for (; nameIndex > 0; nameIndex--)
{
if (xName[nameIndex] != '.')
{
break;
}
}
//Substring to remove the periods
xName = xName.Substring(0, nameIndex + 1);
}
} else {
string xEntry = xData.GetAsciiString(i, 11);
xName = xEntry.Substring(0, 8).TrimEnd();

View file

@ -2,6 +2,9 @@
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
using FAT = Cosmos.System.Filesystem.FAT;
using Cosmos.Hardware.BlockDevice;
using Cosmos.System.Filesystem.FAT;
namespace EdNuttingsTest
{
@ -9,6 +12,140 @@ namespace EdNuttingsTest
{
protected override void Run()
{
try
{
Console.ReadLine();
Console.WriteLine();
Console.WriteLine("Block devices found: " + BlockDevice.Devices.Count);
AtaPio xATA = null;
for (int i = 0; i < BlockDevice.Devices.Count; i++)
{
var xDevice = BlockDevice.Devices[i];
if (xDevice is AtaPio)
{
xATA = (AtaPio)xDevice;
}
}
//Info
Console.WriteLine("--------------------------");
Console.WriteLine("Type: " + (xATA.DriveType == AtaPio.SpecLevel.ATA ? "ATA" : "ATAPI"));
Console.WriteLine("Serial No: " + xATA.SerialNo);
Console.WriteLine("Firmware Rev: " + xATA.FirmwareRev);
Console.WriteLine("Model No: " + xATA.ModelNo);
Console.WriteLine("Block Size: " + xATA.BlockSize + " bytes");
Console.WriteLine("Size: " + xATA.BlockCount * xATA.BlockSize / 1024 / 1024 + " MB");
//Partition Detecting
Partition xPartition = null;
if (BlockDevice.Devices.Count > 0)
{
for (int i = 0; i < BlockDevice.Devices.Count; i++)
{
var xDevice = BlockDevice.Devices[i];
if (xDevice is Partition)
{
xPartition = (Partition)xDevice;
Console.WriteLine("FAT FS");
var xFS = new FAT.FatFileSystem(xPartition);
Console.WriteLine("Mapping...");
Sys.Filesystem.FileSystem.AddMapping("C", xFS);
Console.WriteLine();
Console.WriteLine("Root directory");
var xListing = xFS.GetRoot();
FAT.Listing.FatFile xRootFile = null;
FAT.Listing.FatFile xKudzuFile = null;
for (int j = 0; j < xListing.Count; j++)
{
var xItem = xListing[j];
if (xItem is Sys.Filesystem.Listing.Directory)
{
//Detecting Dir in HDD
Console.WriteLine("<DIR> " + xListing[j].Name);
}
else if (xItem is Sys.Filesystem.Listing.File)
{
//Detecting File in HDD
Console.WriteLine("<FILE> " + xListing[j].Name + " (" + xListing[j].Size + ")");
if (xListing[j].Name == "Root.txt")
{
xRootFile = (FAT.Listing.FatFile)xListing[j];
}
else if (xListing[j].Name == "Kudzu.txt")
{
xKudzuFile = (FAT.Listing.FatFile)xListing[j];
}
}
}
try
{
Console.WriteLine();
Console.WriteLine("StreamReader - Root.txt File");
var xStream = new FAT.FatStream(xRootFile);
var xData = new byte[xRootFile.Size];
xStream.Read(xData, 0, (int)xData.Length);
var xText = Encoding.ASCII.GetString(xData);
Console.WriteLine(xText);
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.Message);
}
try
{
Console.WriteLine();
Console.WriteLine("StreamReader - Kudzu.txt File");
var xStream = new FAT.FatStream(xKudzuFile);
var xData = new byte[xKudzuFile.Size];
xStream.Read(xData, 0, (int)xData.Length);
var xText = Encoding.ASCII.GetString(xData);
Console.WriteLine(xText);
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.Message);
}
//var xKudzuStream = new Sys.Filesystem.FAT.FatStream(xKudzuFile);
//var xKudzuData = new byte[xKudzuFile.Size];
//xKudzuStream.Read(xKudzuData, 0, (int)xKudzuFile.Size);
try
{
//Console.WriteLine();
//Console.WriteLine("FileStream - Root File");
//var xRootFileStream = new System.IO.FileStream(@"c:\Root.txt", System.IO.FileMode.Open);
//var xData = new byte[xRootFileStream.Length];
//xRootFileStream.Read(xData, 0, (int)xRootFile.Size);
//var xText = Encoding.ASCII.GetString(xData);
//Console.WriteLine(xText);
}
catch(Exception e)
{
Console.WriteLine("Error: " + e.Message);
}
}
}
}
else
{
Console.WriteLine("No Block Device Found! ");
}
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.Message);
}
}
}
}