From cbd1b81ffb83da8a8b017d8b040fa64d16e99396 Mon Sep 17 00:00:00 2001 From: EdwardNutting_cp <4a0e5eaa1e4f1b941b4d24194acb591771a0e595xmSctDn6> Date: Tue, 4 Feb 2014 16:27:16 +0000 Subject: [PATCH] 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. --- source/Cosmos.sln | 2 - source2/Cosmos.Assembler/LabelName.cs | 2 +- source2/IL2CPU/Cosmos.IL2CPU/PlugManager.cs | 4 +- .../Cosmos.IL2CPU/Plugs/System/Buffer.cs | 5 + .../Filesystem/FAT/FatFileSystem.cs | 18 ++- .../Users/EdNutting/EdNuttingsTest/Kernel.cs | 137 ++++++++++++++++++ 6 files changed, 162 insertions(+), 6 deletions(-) diff --git a/source/Cosmos.sln b/source/Cosmos.sln index 30d2cc4fa..3c82985dd 100644 --- a/source/Cosmos.sln +++ b/source/Cosmos.sln @@ -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}" diff --git a/source2/Cosmos.Assembler/LabelName.cs b/source2/Cosmos.Assembler/LabelName.cs index e4efec995..a18b1a4e3 100644 --- a/source2/Cosmos.Assembler/LabelName.cs +++ b/source2/Cosmos.Assembler/LabelName.cs @@ -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); diff --git a/source2/IL2CPU/Cosmos.IL2CPU/PlugManager.cs b/source2/IL2CPU/Cosmos.IL2CPU/PlugManager.cs index 9eddf5d82..aef12aa5c 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/PlugManager.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/PlugManager.cs @@ -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; diff --git a/source2/IL2CPU/Cosmos.IL2CPU/Plugs/System/Buffer.cs b/source2/IL2CPU/Cosmos.IL2CPU/Plugs/System/Buffer.cs index fb81a2c3a..fce0adff7 100644 --- a/source2/IL2CPU/Cosmos.IL2CPU/Plugs/System/Buffer.cs +++ b/source2/IL2CPU/Cosmos.IL2CPU/Plugs/System/Buffer.cs @@ -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) { } diff --git a/source2/Kernel/System/Cosmos.System/Filesystem/FAT/FatFileSystem.cs b/source2/Kernel/System/Cosmos.System/Filesystem/FAT/FatFileSystem.cs index 58c272354..909d9d4e0 100644 --- a/source2/Kernel/System/Cosmos.System/Filesystem/FAT/FatFileSystem.cs +++ b/source2/Kernel/System/Cosmos.System/Filesystem/FAT/FatFileSystem.cs @@ -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(); diff --git a/source2/Users/EdNutting/EdNuttingsTest/Kernel.cs b/source2/Users/EdNutting/EdNuttingsTest/Kernel.cs index f52143d81..c32f8e9d9 100644 --- a/source2/Users/EdNutting/EdNuttingsTest/Kernel.cs +++ b/source2/Users/EdNutting/EdNuttingsTest/Kernel.cs @@ -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("