Skip to content

Commit

Permalink
-Merge (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil committed May 14, 2023
1 parent 4e9a435 commit 24d4740
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 33 deletions.
16 changes: 0 additions & 16 deletions Source/Mosa.Kernel.BareMetal.x86/PageTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,27 @@ internal static class PageTable

public static void Setup()
{
//Console.WriteLine("Mosa.Kernel.BareMetal.x86.PageTable.Setup:Enter");
GDTTable = new GDTTable(PhysicalPageAllocator.ReservePage());

PageDirectory = PhysicalPageAllocator.ReservePages(1024);
PageTables = PhysicalPageAllocator.ReservePages(1024);

//Console.WriteLine("Mosa.Kernel.BareMetal.x86.PageTable.Setup:Exit");
}

public static void Initialize()
{
Console.WriteLine("Mosa.Kernel.BareMetal.x86.PageTable.Initialize:Enter");

GDTTable.Setup();

Console.WriteLine("Mosa.Kernel.BareMetal.x86.PageTable.Initialize:1");

// Setup Page Directory
for (uint index = 0; index < 1024; index++)
{
PageDirectory.Store32(index << 2, (PageTables.ToUInt32() + index * Page.Size) | 0x04 | 0x02 | 0x01);
}

Console.WriteLine("Mosa.Kernel.BareMetal.x86.PageTable.Initialize:2");

// Clear the Page Tables
for (uint index = 0; index < 1024; index++)
{
Console.WriteValue(index);

PageTables.Store32(index << 2, (index * Page.Size) | 0x04 | 0x02 | 0x01);

Console.Write(' ');
}

Console.WriteLine("Mosa.Kernel.BareMetal.x86.PageTable.Initialize:Exit");
while (true) { }
}

public static void Enable()
Expand Down
14 changes: 6 additions & 8 deletions Source/Mosa.Kernel.BareMetal/PageTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ public static class PageTable
{
public static void Setup()
{
Console.WriteLine("Mosa.Kernel.BareMetal.PageTable.Setup:Enter");
Platform.PageTableSetup();

Console.WriteLine("Mosa.Kernel.BareMetal.PageTable.Setup:1");
Platform.PageTableInitialize();

Console.WriteLine("Mosa.Kernel.BareMetal.PageTable.Setup:2");

while (true) { }

// Unmap the first page for null pointer exceptions
MapVirtualAddressToPhysical(0x0, 0x0, false);
Console.Write("d");

Console.WriteLine("Mosa.Kernel.BareMetal.PageTable.Setup:1");

while (true) { } // Platform.PageTableEnable() crashes

Platform.PageTableEnable();
Console.Write("e");

Console.WriteLine("Mosa.Kernel.BareMetal.PageTable.Setup:2");
}

/// <summary>
Expand Down
9 changes: 0 additions & 9 deletions Source/Mosa.Kernel.BareMetal/PhysicalPageAllocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,18 @@ public static Pointer ReservePages(uint count, uint alignment = 1)
// not aligned
// todo - skip to next aligned address rather then just increment
restartAt = at + 1;

//Console.Write('.');
}
else if (CheckFreePage32(at, count, out restartAt))
{
// found space!
//Console.Write('X');
SetPageBitMapEntry(at, count, true);

//Console.Write('o');
SearchNextStartPage = restartAt;

//Console.WriteLine();

return new Pointer(at * Page.Size);
}
else
{
//Console.Write('-');
at = restartAt;
}

Expand All @@ -178,8 +171,6 @@ public static Pointer ReservePages(uint count, uint alignment = 1)

if (at < start && restartAt > start)
{
//Console.WriteLine("NONE");

// looped around in the search
// quit, as there are no free pages
return Pointer.Zero;
Expand Down

0 comments on commit 24d4740

Please sign in to comment.