From a1577ccfcfb620fa13d8d4d5b539f43f9b606abe Mon Sep 17 00:00:00 2001 From: Kudzu Date: Thu, 9 Jun 2016 19:42:13 -0400 Subject: [PATCH 1/6] stuff --- Docs/Kernel/Memory.md | 62 +++++++++++++++++++++++++++++++++++- Docs/Kernel/MemoryManager.md | 42 ------------------------ 2 files changed, 61 insertions(+), 43 deletions(-) delete mode 100644 Docs/Kernel/MemoryManager.md diff --git a/Docs/Kernel/Memory.md b/Docs/Kernel/Memory.md index 844b3747c..e6ce8f6b8 100644 --- a/Docs/Kernel/Memory.md +++ b/Docs/Kernel/Memory.md @@ -1 +1,61 @@ -On initialization of the kernel, a GlobalInformationTable is setup. This contains the address of the first DataLookupEntry \ No newline at end of file +# Layout + +F..F +Stack + Currently only one stack as we don't have threads yet. Stack resides at top of RAM and grows down. +.... +Data + +Text + Syslinux Boot Code + Cosmos Boot Code + Kernel + Apps (Monolithic currently) +0..0 + +# OLD BELOW THIS POINT + +On initialization of the kernel, a GlobalInformationTable is setup. This contains the address of the first DataLookupEntry + +# The Memory Manager + +The manager will init itself if there are no blocks. The manager is modeled after a double LinkedList and is not a List. + +# Memory Layout +The layout does not have a preset list or table but rather every item has meta data linking the next and previous item. This allows for a robust system. + +The data layout is as follows: + +```` +Block|Block|Block etc. + +Block = + +Meta Data|Data + +Meta data = +4 bytes (preveus block address start)|4 bytes (next block address start)|4 bytes (curent[this] block size)| 4 bytes (curent[this] block flag) +``` +BlockFlags : + +``` +Allocated = 0, +Free = 1, +``` + +the final layout looks like this: + +``` +4 bytes|4 bytes|4 bytes|4 bytes | (size of Block) bytes | 4 bytes|4 bytes|4 bytes | 4 bytes | (size of Block) bytes | etc + +``` +Note: +this means the smallest size an Block can occupy is 17 bytes, 16 bytes for the header and 1 for the smallest data type a byte. + +# Usage + +### Allocation + Allocating a block happens by finding the first free block and split it (if necessary). + +## Deallocation + Freeing a block is easy set its flag (in the metadata) to free. diff --git a/Docs/Kernel/MemoryManager.md b/Docs/Kernel/MemoryManager.md deleted file mode 100644 index e42bca00b..000000000 --- a/Docs/Kernel/MemoryManager.md +++ /dev/null @@ -1,42 +0,0 @@ -# The Memory Manager - -The manager will init itself if there are no blocks. The manager is modeled after a double LinkedList and is not a List. - -# Memory Layout -The layout does not have a preset list or table but rather every item has meta data linking the next and previous item. This allows for a robust system. - -The data layout is as follows: - -```` -Block|Block|Block etc. - -Block = - -Meta Data|Data - -Meta data = -4 bytes (preveus block address start)|4 bytes (next block address start)|4 bytes (curent[this] block size)| 4 bytes (curent[this] block flag) -``` -BlockFlags : - -``` -Allocated = 0, -Free = 1, -``` - -the final layout looks like this: - -``` -4 bytes|4 bytes|4 bytes|4 bytes | (size of Block) bytes | 4 bytes|4 bytes|4 bytes | 4 bytes | (size of Block) bytes | etc - -``` -Note: -this means the smallest size an Block can occupy is 17 bytes, 16 bytes for the header and 1 for the smallest data type a byte. - -# Usage - -### Allocation - Allocating a block happens by finding the first free block and split it (if necessary). - -## Deallocation - Freeing a block is easy set its flag (in the metadata) to free. From 1fc8f615dad357893fcd1e46523da57ad8014826 Mon Sep 17 00:00:00 2001 From: Kudzu Date: Thu, 9 Jun 2016 19:42:28 -0400 Subject: [PATCH 2/6] stuff --- Docs/Kernel/Memory.md | 51 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/Docs/Kernel/Memory.md b/Docs/Kernel/Memory.md index e6ce8f6b8..89a799f3b 100644 --- a/Docs/Kernel/Memory.md +++ b/Docs/Kernel/Memory.md @@ -1,17 +1,60 @@ # Layout +``` F..F + Stack Currently only one stack as we don't have threads yet. Stack resides at top of RAM and grows down. + In future each process will have its own stack in DATA. And Stack master section will be eliminated. .... + Data + -Heap + Global heap for all processes since compiler enforces references. Text - Syslinux Boot Code - Cosmos Boot Code - Kernel - Apps (Monolithic currently) + All sections are fixed in size and are stacked. + -Syslinux Boot Code + -Cosmos Boot Code + -Kernel + -Apps (Monolithic currently, will move to DATA later) + -Legacy GDT + -IDT + -Page Tables + 0..0 +``` + +``` +MM API +-Allocate new item +-Add/remove ref +-Lock/unlock an item +-Force a compact + +Implicit +-Get pointer + +Internal +-Compact +-Relocate items + +Properties +-Ref count +-Lock status +-Size + +Handles +-Use indirect pointers via a lookup table. Handle is ptr to table. Global table to save space. + -No way to compact tables? + -use linked list of tables to allow some compaction? + -Allocate tables to processes so they will go away 100% when process goes way since its not fully shrinkable. + -Keep in data space in future? + -Small tables increase compaction opportunities +-Points to actual data +-Properties are before pointer +-In atomic ops (IL emit groups) - pointer can be grabbed and stored +``` # OLD BELOW THIS POINT From e328b44c6ef14ddfe7bd1b37dbd376eaac7f070c Mon Sep 17 00:00:00 2001 From: Kudzu Date: Thu, 9 Jun 2016 20:04:42 -0400 Subject: [PATCH 3/6] CRAM shell and test --- source/Cosmos.Core.Memory.Test/CRAM.cs | 10 +++ .../Cosmos.Core.Memory.Test.csproj | 84 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++ source/Cosmos.Core.Memory.Test/UnitTest1.cs | 11 +++ source/Cosmos.sln | 15 ++++ 5 files changed, 156 insertions(+) create mode 100644 source/Cosmos.Core.Memory.Test/CRAM.cs create mode 100644 source/Cosmos.Core.Memory.Test/Cosmos.Core.Memory.Test.csproj create mode 100644 source/Cosmos.Core.Memory.Test/Properties/AssemblyInfo.cs create mode 100644 source/Cosmos.Core.Memory.Test/UnitTest1.cs diff --git a/source/Cosmos.Core.Memory.Test/CRAM.cs b/source/Cosmos.Core.Memory.Test/CRAM.cs new file mode 100644 index 000000000..0fbb7e5f1 --- /dev/null +++ b/source/Cosmos.Core.Memory.Test/CRAM.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cosmos.Core.Memory.Test { + static public class CRAM { + } +} diff --git a/source/Cosmos.Core.Memory.Test/Cosmos.Core.Memory.Test.csproj b/source/Cosmos.Core.Memory.Test/Cosmos.Core.Memory.Test.csproj new file mode 100644 index 000000000..16647507d --- /dev/null +++ b/source/Cosmos.Core.Memory.Test/Cosmos.Core.Memory.Test.csproj @@ -0,0 +1,84 @@ + + + + Debug + AnyCPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B} + Library + Properties + Cosmos.Core.Memory.Test + Cosmos.Core.Memory.Test + v4.5.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file diff --git a/source/Cosmos.Core.Memory.Test/Properties/AssemblyInfo.cs b/source/Cosmos.Core.Memory.Test/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..2d449f074 --- /dev/null +++ b/source/Cosmos.Core.Memory.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +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("Cosmos.Core.Memory.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Cosmos.Core.Memory.Test")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("901ea2c4-5e9c-44e8-b6d2-3b23dee6d61b")] + +// 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 Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/source/Cosmos.Core.Memory.Test/UnitTest1.cs b/source/Cosmos.Core.Memory.Test/UnitTest1.cs new file mode 100644 index 000000000..1c0956971 --- /dev/null +++ b/source/Cosmos.Core.Memory.Test/UnitTest1.cs @@ -0,0 +1,11 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Cosmos.Core.Memory.Test { + [TestClass] + public class UnitTest1 { + [TestMethod] + public void TestMethod1() { + } + } +} diff --git a/source/Cosmos.sln b/source/Cosmos.sln index caaa3355f..e4dabd26f 100644 --- a/source/Cosmos.sln +++ b/source/Cosmos.sln @@ -249,6 +249,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Compiler.Tests.Metho EndProject Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "Cosmos.Compiler.Tests.MethodTestsBoot", "..\Tests\Cosmos.Compiler.Tests.MethodTests\Cosmos.Compiler.Tests.MethodTestsBoot.Cosmos", "{0FEE977D-AE52-4381-B513-71C5C1982ED4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Core.Memory.Test", "Cosmos.Core.Memory.Test\Cosmos.Core.Memory.Test.csproj", "{901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1105,6 +1107,18 @@ Global {0FEE977D-AE52-4381-B513-71C5C1982ED4}.Release|x64.Build.0 = Debug|x86 {0FEE977D-AE52-4381-B513-71C5C1982ED4}.Release|x86.ActiveCfg = Debug|x86 {0FEE977D-AE52-4381-B513-71C5C1982ED4}.Release|x86.Build.0 = Debug|x86 + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|x64.ActiveCfg = Debug|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|x64.Build.0 = Debug|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|x86.ActiveCfg = Debug|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|x86.Build.0 = Debug|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|Any CPU.Build.0 = Release|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|x64.ActiveCfg = Release|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|x64.Build.0 = Release|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|x86.ActiveCfg = Release|Any CPU + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1204,5 +1218,6 @@ Global {C1D525C4-B072-4F2F-94BF-4862E6727C4B} = {9637A680-F8E9-4925-A4E4-00045205EC04} {FE8B9F39-7C96-4866-9A18-386735895CEE} = {F104F6BC-EF8E-4408-A786-D570D7565231} {0FEE977D-AE52-4381-B513-71C5C1982ED4} = {F104F6BC-EF8E-4408-A786-D570D7565231} + {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B} = {9637A680-F8E9-4925-A4E4-00045205EC04} EndGlobalSection EndGlobal From 569e707edd4926ed76f1b0cb3524fff4d389b67b Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Thu, 9 Jun 2016 22:11:29 -0500 Subject: [PATCH 4/6] Restore nuget packages. --- appveyor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index b1a309636..1c2600c09 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,6 +8,9 @@ build_script: rem %APPVEYOR_BUILD_FOLDER% + nuget restore "source\Cosmos.sln" + + msbuild "source\Builder.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform=x86 /p:Configuration=Debug /p:DeployExtension=false From 3628b65d29df98c4aa793d7e82a42700b5756ad9 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Fri, 10 Jun 2016 08:55:59 -0500 Subject: [PATCH 5/6] Added testresults artifact. --- appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 1c2600c09..9462513f8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -53,4 +53,6 @@ notifications: on_build_failure: true on_build_status_changed: true matrix: - fast_finish: true \ No newline at end of file + fast_finish: true +artifacts: + - path: source\TestResults\TestResult.xml \ No newline at end of file From 40c1f6dbc673f4666fce4e1b1038632d5ad19060 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Fri, 10 Jun 2016 10:01:47 -0500 Subject: [PATCH 6/6] Testing appveyor artifacts. --- Users/Matthijs/DebugCompiler/MyEngine.cs | 54 ++++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/Users/Matthijs/DebugCompiler/MyEngine.cs b/Users/Matthijs/DebugCompiler/MyEngine.cs index 460cb0227..0fc8384d4 100644 --- a/Users/Matthijs/DebugCompiler/MyEngine.cs +++ b/Users/Matthijs/DebugCompiler/MyEngine.cs @@ -8,39 +8,39 @@ namespace DebugCompiler [TestFixture] public class RunKernels { - [Test] - public void Test([ValueSource(typeof(MySource), nameof(MySource.ProvideData))] Type kernelToRun) - { - var xEngine = new Engine(); - // Sets the time before an error is registered. For example if set to 60 then if a kernel runs for more than 60 seconds then - // that kernel will be marked as a failiure and terminated - xEngine.AllowedSecondsInKernel = 1800; + //[Test] + //public void Test([ValueSource(typeof(MySource), nameof(MySource.ProvideData))] Type kernelToRun) + //{ + // var xEngine = new Engine(); + // // Sets the time before an error is registered. For example if set to 60 then if a kernel runs for more than 60 seconds then + // // that kernel will be marked as a failiure and terminated + // xEngine.AllowedSecondsInKernel = 1800; - // If you want to test only specific platforms, add them to the list, like next line. By default, all platforms are run. - xEngine.RunTargets.Add(RunTargetEnum.Bochs); + // // If you want to test only specific platforms, add them to the list, like next line. By default, all platforms are run. + // xEngine.RunTargets.Add(RunTargetEnum.Bochs); - // If you're working on the compiler (or other lower parts), you can choose to run the compiler in process - // one thing to keep in mind though, is that this only works with 1 kernel at a time! - xEngine.RunIL2CPUInProcess = false; - xEngine.TraceAssembliesLevel = TraceAssemblies.User; - xEngine.EnableStackCorruptionChecks = true; - xEngine.StackCorruptionChecksLevel = StackCorruptionDetectionLevel.AllInstructions; + // // If you're working on the compiler (or other lower parts), you can choose to run the compiler in process + // // one thing to keep in mind though, is that this only works with 1 kernel at a time! + // xEngine.RunIL2CPUInProcess = false; + // xEngine.TraceAssembliesLevel = TraceAssemblies.User; + // xEngine.EnableStackCorruptionChecks = true; + // xEngine.StackCorruptionChecksLevel = StackCorruptionDetectionLevel.AllInstructions; - // Select kernels to be tested by adding them to the engine - xEngine.AddKernel(kernelToRun.Assembly.Location); + // // Select kernels to be tested by adding them to the engine + // xEngine.AddKernel(kernelToRun.Assembly.Location); - xEngine.OutputHandler = new TestOutputHandler(); + // xEngine.OutputHandler = new TestOutputHandler(); - Assert.IsTrue(xEngine.Execute()); + // Assert.IsTrue(xEngine.Execute()); - } + //} - private class TestOutputHandler: OutputHandlerFullTextBase - { - protected override void Log(string message) - { - TestContext.WriteLine(String.Concat(DateTime.Now.ToString("hh:mm:ss.ffffff "), new String(' ', mLogLevel * 2), message)); - } - } + //private class TestOutputHandler: OutputHandlerFullTextBase + //{ + // protected override void Log(string message) + // { + // TestContext.WriteLine(String.Concat(DateTime.Now.ToString("hh:mm:ss.ffffff "), new String(' ', mLogLevel * 2), message)); + // } + //} } }