forked from mosa/MOSA-Project
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
98 changed files
with
516 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading; | ||
using Mosa.Kernel.BareMetal; | ||
using Mosa.UnitTests.Optimization; | ||
|
||
namespace Mosa.BareMetal.TestWorld.x64; | ||
|
||
public static class Boot | ||
{ | ||
public static void Main() | ||
{ | ||
Debug.WriteLine("Boot::Main()"); | ||
|
||
Console.BackgroundColor = ConsoleColor.Blue; | ||
Console.ForegroundColor = ConsoleColor.White; | ||
Console.Clear(); | ||
Console.WriteLine("Mosa.BareMetal.TextWorld.x64"); | ||
Console.WriteLine(); | ||
|
||
Division.DivisionBy7(254u); | ||
|
||
//InterruptManager.SetHandler(ProcessInterrupt); | ||
|
||
//StartThreading(); | ||
|
||
// Will never get here! | ||
//Debug.WriteLine("ERROR: Thread Start Failure"); | ||
|
||
Debug.WriteLine("ERROR: Done!"); | ||
Debug.Fatal(); | ||
} | ||
|
||
private static int counter = 0; | ||
|
||
public static void ProcessInterrupt(uint interrupt, uint errorCode) | ||
{ | ||
Interlocked.Increment(ref counter); | ||
|
||
lock (spinlock) | ||
{ | ||
Console.SetCursorPosition(0, 23); | ||
Console.Write("Counter: " + counter + " IRQ: " + interrupt + " Code: " + errorCode); | ||
} | ||
} | ||
|
||
private static void StartThreading() | ||
{ | ||
Debug.WriteLine("Boot::StartThreadTest()"); | ||
|
||
Scheduler.CreateThread(Program.EntryPoint); | ||
|
||
Scheduler.CreateThread(Thread1); | ||
Scheduler.CreateThread(Thread2); | ||
Scheduler.CreateThread(Thread3); | ||
Scheduler.CreateThread(Thread4); | ||
Scheduler.CreateThread(Thread5); | ||
|
||
Scheduler.Start(); | ||
|
||
Debug.WriteLine("Boot::StartThreadTest() [Exit]"); | ||
} | ||
|
||
private static readonly object spinlock = new(); | ||
private static int totalticks = 0; | ||
|
||
private static void UpdateThreadTicks(int thread, uint ticks) | ||
{ | ||
Interlocked.Increment(ref totalticks); | ||
|
||
if (totalticks % 10000 == 0) | ||
{ | ||
lock (spinlock) | ||
{ | ||
Console.SetCursorPosition(0, 1 + thread); | ||
Console.Write("Thread #" + thread + ": " + ticks); | ||
} | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static void Thread1() | ||
{ | ||
var ticks = 0u; | ||
|
||
while (true) | ||
{ | ||
UpdateThreadTicks(1, ++ticks); | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static void Thread2() | ||
{ | ||
var ticks = 0u; | ||
|
||
while (true) | ||
{ | ||
UpdateThreadTicks(2, ++ticks); | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static void Thread3() | ||
{ | ||
var ticks = 0u; | ||
|
||
while (true) | ||
{ | ||
UpdateThreadTicks(3, ++ticks); | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static void Thread4() | ||
{ | ||
var ticks = 0u; | ||
|
||
while (true) | ||
{ | ||
UpdateThreadTicks(4, ++ticks); | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static void Thread5() | ||
{ | ||
var ticks = 0u; | ||
|
||
while (true) | ||
{ | ||
UpdateThreadTicks(5, ++ticks); | ||
} | ||
} | ||
|
||
public static void ForceInclude() | ||
{ | ||
Mosa.Kernel.BareMetal.x64.PlatformPlug.ForceInclude(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Source/Mosa.BareMetal.TestWorld.x64/Mosa.BareMetal.TestWorld.x64.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
|
||
<Import Project="../Mosa.BareMetal.targets" /> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Mosa.BareMetal.TestWorld\Mosa.BareMetal.TestWorld.csproj" /> | ||
<ProjectReference Include="..\Mosa.Kernel.BareMetal.x64\Mosa.Kernel.BareMetal.x64.csproj" /> | ||
<ProjectReference Include="..\Mosa.UnitTests\Mosa.UnitTests.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.