diff --git a/Demos/Guess/Guess.Cosmos b/Demos/Guess/Guess.Cosmos index 8d57ca7ae5..d28b916e5b 100644 --- a/Demos/Guess/Guess.Cosmos +++ b/Demos/Guess/Guess.Cosmos @@ -15,7 +15,7 @@ v4.5.2 - Bochs + VMware true bin\Debug\ MicrosoftNET @@ -26,13 +26,13 @@ PXE Player False - Workstation + Player ISO False ISO - Bochs + VMware True - User + All PXE None False @@ -82,7 +82,7 @@ False false Guess - Use Bochs emulator to deploy and debug. + Use VMware Player or Workstation to deploy and debug. User 001 Creates a bootable ISO image which can be burned to a DVD. After running the selected project, an explorer window will open containing the ISO file. The ISO file can then be burned to a CD or DVD and used to boot a physical or virtual system. Guess @@ -129,7 +129,7 @@ Pipe: Cosmos\Serial False Pipe: Cosmos\Serial - True + False False Guess Use Bochs emulator to deploy and debug. @@ -181,9 +181,10 @@ False AllInstructions AllInstructions + AllInstructions - Bochs + VMware true bin\Debug\ MicrosoftNET @@ -194,13 +195,13 @@ PXE Player False - Workstation + Player ISO False ISO - Bochs + VMware True - User + All PXE None False @@ -250,7 +251,7 @@ False false Guess - Use Bochs emulator to deploy and debug. + Use VMware Player or Workstation to deploy and debug. User 001 Creates a bootable ISO image which can be burned to a DVD. After running the selected project, an explorer window will open containing the ISO file. The ISO file can then be burned to a CD or DVD and used to boot a physical or virtual system. Guess @@ -303,7 +304,7 @@ False False False - True + False False Guess Use Bochs emulator to deploy and debug. @@ -355,6 +356,7 @@ False AllInstructions AllInstructions + AllInstructions diff --git a/Demos/Guess/GuessOS.cs b/Demos/Guess/GuessOS.cs index 5e65ee3254..f08a409901 100644 --- a/Demos/Guess/GuessOS.cs +++ b/Demos/Guess/GuessOS.cs @@ -10,7 +10,7 @@ namespace GuessKernel public class GuessOS : Sys.Kernel { protected int mCount = 0; - + protected int mMagicNo = 22; public GuessOS() @@ -18,7 +18,7 @@ public GuessOS() // Didnt check if tickcount is working yet.. can change this later //var xRandom = new Random(234243534); //mMagicNo = xRandom.Next(1, 100); - } + } protected override void BeforeRun() { diff --git a/Demos/zMachine/Frotz.Net/source/zConsole/Program.cs b/Demos/zMachine/Frotz.Net/source/zConsole/Program.cs index ab4f5f9b76..ab61641d5f 100644 --- a/Demos/zMachine/Frotz.Net/source/zConsole/Program.cs +++ b/Demos/zMachine/Frotz.Net/source/zConsole/Program.cs @@ -24,7 +24,7 @@ static void Main(string[] args) Frotz.os_.debug_mode = false; //if (File.Exists("debug.log")) // File.Delete("debug.log"); - string fName = ""; + string fName = args[0]; //while(!File.Exists(fName)) //{ // Console.WriteLine("Please type a path to a storyfile:"); diff --git a/Docs/Kernel/Levels.md b/Docs/Kernel/Levels.md index 6c4cb4b2c8..e6db6cac0e 100644 --- a/Docs/Kernel/Levels.md +++ b/Docs/Kernel/Levels.md @@ -119,6 +119,9 @@ Things that Core implements and exposes to HAL: Core also manages consumers of its services to avoid conflicts and security to prevent a specific driver from accessing "everything". +Notes: +https://github.com/joeduffy/slice.net + ### 1 HAL (Hardware Abstraction Layer) Summary: Hardware control @@ -191,7 +194,7 @@ references. ## Graphics 0 IO/Memory access (Cosmos) -1 DirectX / Graphics Memory +1 DirectX / VESA / Graphics Memory 2 WinForms, WPF, Other UI, Canvas, JPG/PNG/GIF 3 Application diff --git a/Tests/Cosmos.Kernel.Tests.Fat/Kernel.cs b/Tests/Cosmos.Kernel.Tests.Fat/Kernel.cs index e01b5caa5d..ee6ba27b58 100644 --- a/Tests/Cosmos.Kernel.Tests.Fat/Kernel.cs +++ b/Tests/Cosmos.Kernel.Tests.Fat/Kernel.cs @@ -1,5 +1,6 @@ using System; using System.IO; + using Cosmos.Common.Extensions; using Cosmos.System.FileSystem; using Cosmos.System.FileSystem.VFS; @@ -728,9 +729,10 @@ private void TestFile() /// private void TestFileStream() { + mDebugger.Send("START TEST: Filestream:"); + using (var xFS = new FileStream(@"0:\Kudzu.txt", FileMode.Create)) { - mDebugger.Send("START TEST: Filestream:"); mDebugger.Send("Start writing"); var xStr = "Test FAT Write."; byte[] xWriteBuff = xStr.GetUtf8Bytes(0, (uint)xStr.Length); diff --git a/source/Cosmos.Common/Extensions/ToHexString.cs b/source/Cosmos.Common/Extensions/ToHexString.cs index ffc216c477..2c0c03e9c4 100644 --- a/source/Cosmos.Common/Extensions/ToHexString.cs +++ b/source/Cosmos.Common/Extensions/ToHexString.cs @@ -1,128 +1,148 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Cosmos.Common.Extensions { - public static class ToHexString { - +namespace Cosmos.Common.Extensions +{ + public static class ToHexString + { //TODO: Can add several more overloads for other numbertypes, with and without width argument. - public static string ToHex(this byte n) { - return ConvertToHex((UInt32)n, 2); + public static string ToHex(this byte n) + { + return ConvertToHex((uint)n, 2); } - public static string ToHex(this byte n, int aWidth) { - return ConvertToHex((UInt32)n, aWidth); + + public static string ToHex(this byte n, int aWidth) + { + return ConvertToHex((uint)n, aWidth); } - public static string ToHex(this int n) { - return ConvertToHex((UInt32)n); + public static string ToHex(this int n) + { + return ConvertToHex((uint)n, 4); } - public static string ToHex(this int n, int aWidth) { - return ConvertToHex((UInt32)n, aWidth); + + public static string ToHex(this int n, int aWidth) + { + return ConvertToHex((uint)n, aWidth); } - public static string ToHex(this UInt16 n) { - return ConvertToHex((UInt32)n, 4); + public static string ToHex(this ushort n) + { + return ConvertToHex((uint)n, 4); } - public static string ToHex(this UInt16 n, int aWidth) { - return ConvertToHex((UInt32)n, aWidth); + + public static string ToHex(this ushort n, int aWidth) + { + return ConvertToHex((uint)n, aWidth); } - public static string ToHex(this uint aValue) { + public static string ToHex(this uint aValue) + { return ConvertToHex(aValue, 8); } - public static string ToHex(this uint aValue, int aWidth) { + + public static string ToHex(this uint aValue, int aWidth) + { return ConvertToHex(aValue, aWidth); } - public static string ToHex(this ulong aValue) { + public static string ToHex(this ulong aValue) + { return ConvertToHex(aValue).PadLeft(16, '0'); } - public static string ToHex(this ulong aValue, int aWidth) { + + public static string ToHex(this ulong aValue, int aWidth) + { return ConvertToHex(aValue).PadLeft(aWidth, '0'); } - private static string GetPrefix() { + private static string GetPrefix() + { return "0x"; } - private static string GetSuffix() { + private static string GetSuffix() + { return "h"; } - private static string ConvertToHex(UInt32 num) { + private static string ConvertToHex(uint num) + { string xHex = string.Empty; - if (num == 0) { - xHex = "0"; - } else { - while (num != 0) { - //Note; char is converted to string because Cosmos crashes when adding char and string. Frode, 7.june. - //TODO: Is this still true? I think Cosmos can handle char + string just fine now. - xHex = SingleDigitToHex((byte)(num & 0xf)) + xHex; - num = num >> 4; - } + if (num == 0) + { + xHex = "0"; + } + else + { + while (num != 0) + { + xHex = DigitToHexChar((byte)(num & 0xf)) + xHex; + num = num >> 4; + } } return xHex; } - private static string ConvertToHex(UInt32 aValue, int aWidth) { + private static string ConvertToHex(uint aValue, int aWidth) + { return ConvertToHex(aValue).PadLeft(aWidth, '0'); } - private static string ConvertToHex(UInt64 num) { + private static string ConvertToHex(ulong num) + { string xHex = string.Empty; - while (num != 0) { + while (num != 0) + { //Note; char is converted to string because Cosmos crashes when adding char and string. Frode, 7.june. - xHex = SingleDigitToHex((byte)(num & 0xf)) + xHex; + xHex = DigitToHexChar((byte)(num & 0xf)) + xHex; num = num >> 4; } return xHex; } - public static string SingleDigitToHex(byte d) { - switch (d) { + public static char DigitToHexChar(byte d) + { + switch (d) + { case 0: - return "0"; + return '0'; case 1: - return "1"; + return '1'; case 2: - return "2"; + return '2'; case 3: - return "3"; + return '3'; case 4: - return "4"; + return '4'; case 5: - return "5"; + return '5'; case 6: - return "6"; + return '6'; case 7: - return "7"; + return '7'; case 8: - return "8"; + return '8'; case 9: - return "9"; + return '9'; case 10: - return "A"; + return 'A'; case 11: - return "B"; + return 'B'; case 12: - return "C"; + return 'C'; case 13: - return "D"; + return 'D'; case 14: - return "E"; + return 'E'; case 15: - return "F"; + return 'F'; } - return " "; + return ' '; } - } } diff --git a/source/Cosmos.System/FileSystem/FAT/Listing/FatDiretoryEntry.cs b/source/Cosmos.System/FileSystem/FAT/Listing/FatDiretoryEntry.cs index 4309a600b9..e286abbd13 100644 --- a/source/Cosmos.System/FileSystem/FAT/Listing/FatDiretoryEntry.cs +++ b/source/Cosmos.System/FileSystem/FAT/Listing/FatDiretoryEntry.cs @@ -229,6 +229,7 @@ public List ReadDirectoryContents() //TODO: Change xLongName to StringBuilder string xLongName = ""; string xName = ""; + for (uint i = 0; i < xData.Length; i = i + 32) { byte xAttrib = xData[i + 11]; @@ -292,7 +293,7 @@ public List ReadDirectoryContents() break; case FatDirectoryEntryAttributeConsts.UnusedOrDeletedEntry: // Empty slot, skip it - break; + continue; default: if (xStatus >= 0x20) { @@ -338,6 +339,7 @@ public List ReadDirectoryContents() break; } } + uint xFirstCluster = (uint)(xData.ToUInt16(i + 20) << 16 | xData.ToUInt16(i + 26)); int xTest = xAttrib & (FatDirectoryEntryAttributeConsts.Directory | FatDirectoryEntryAttributeConsts.VolumeID); @@ -458,6 +460,7 @@ internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata aEntryMet if (mParent != null) { var xData = ((FatDirectoryEntry)mParent).GetDirectoryEntryData(); + if (xData.Length > 0) { var xValue = new byte[aEntryMetadata.DataLength]; @@ -482,6 +485,7 @@ internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata aEntryMet if (mParent != null) { var xData = ((FatDirectoryEntry)mParent).GetDirectoryEntryData(); + if (xData.Length > 0) { var xValue = new byte[aEntryMetadata.DataLength]; @@ -506,6 +510,7 @@ internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata aEntryMet Global.mFileSystemDebugger.SendInternal(aValue); var xData = ((FatDirectoryEntry)mParent).GetDirectoryEntryData(); + if (xData.Length > 0) { var xValue = new byte[aEntryMetadata.DataLength];