mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 22:12:25 +00:00
Merge branch 'master' of https://github.com/CosmosOS/Cosmos.git
This commit is contained in:
commit
bd3f361fcc
9 changed files with 263 additions and 45 deletions
|
|
@ -1 +1,104 @@
|
|||
On initialization of the kernel, a GlobalInformationTable is setup. This contains the address of the first DataLookupEntry
|
||||
# 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
|
||||
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
|
||||
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -14,13 +14,14 @@
|
|||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
|
|
|
|||
10
source/Cosmos.Core.Memory.Test/CRAM.cs
Normal file
10
source/Cosmos.Core.Memory.Test/CRAM.cs
Normal file
|
|
@ -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 {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Cosmos.Core.Memory.Test</RootNamespace>
|
||||
<AssemblyName>Cosmos.Core.Memory.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
</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>
|
||||
</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="System" />
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
|
||||
</ItemGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="CRAM.cs" />
|
||||
<Compile Include="UnitTest1.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<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>
|
||||
36
source/Cosmos.Core.Memory.Test/Properties/AssemblyInfo.cs
Normal file
36
source/Cosmos.Core.Memory.Test/Properties/AssemblyInfo.cs
Normal file
|
|
@ -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")]
|
||||
11
source/Cosmos.Core.Memory.Test/UnitTest1.cs
Normal file
11
source/Cosmos.Core.Memory.Test/UnitTest1.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Cosmos.Core.Memory.Test {
|
||||
[TestClass]
|
||||
public class UnitTest1 {
|
||||
[TestMethod]
|
||||
public void TestMethod1() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
SysReflection.FieldInfo xField = xOpCode.Value;
|
||||
// call cctor:
|
||||
var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault();
|
||||
if (xCctor != null)
|
||||
if (xCctor != null && xCctor.DeclaringType != aMethod.MethodBase.DeclaringType)
|
||||
{
|
||||
new CPUx86.Call { DestinationLabel = LabelName.Get(xCctor) };
|
||||
ILOp.EmitExceptionLogic(Assembler, aMethod, aOpCode, true, null, ".AfterCCTorExceptionCheck");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue