-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass Boot Options string to the Kernel (#1117)
* - WIP - ARMv8A32 * - WIP - ARMv8A32 * - Updated builds.yml * - Updated builds.yml * - Updated builds.yml * - Updated builds.yml * - WIP - x64 * More BareMetal changes * Update Mosa.Kernel.x86.ConsolePlug * Fix IDT issue * - WIP * - WIP * - WIP * - WIP * - WIP * - WIP * - WIP * - WIP * - WIP * - WIP --------- Co-authored-by: AnErrupTion <anerruption@disroot.org>
- Loading branch information
1 parent
2f85b46
commit 5a3cb20
Showing
25 changed files
with
260 additions
and
106 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
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
29 changes: 29 additions & 0 deletions
29
Source/Mosa.Compiler.Framework/CompilerStages/BootOptionStage.cs
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,29 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
using System.IO; | ||
using Mosa.Compiler.Common; | ||
using Mosa.Compiler.Framework.Linker; | ||
|
||
namespace Mosa.Compiler.Framework.CompilerStages; | ||
|
||
/// <summary> | ||
/// Emit boot options | ||
/// </summary> | ||
/// <seealso cref="Mosa.Compiler.Framework.BaseCompilerStage" /> | ||
public class BootOptionStage : BaseCompilerStage | ||
{ | ||
protected override void Finalization() | ||
{ | ||
var bootOptions = Linker.DefineSymbol(Metadata.BootOptions, SectionKind.ROData, TypeLayout.NativePointerAlignment, 0); | ||
var writer = new BinaryWriter(bootOptions.Stream); | ||
|
||
if (MosaSettings.OSBootOptions == null) | ||
{ | ||
writer.WriteByte(0); | ||
} | ||
else | ||
{ | ||
writer.WriteNullTerminatedString(MosaSettings.OSBootOptions); | ||
} | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
Source/Mosa.Compiler.Framework/Intrinsics/GetBootOptions.cs
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 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
namespace Mosa.Compiler.Framework.Intrinsics; | ||
|
||
/// <summary> | ||
/// IntrinsicMethods | ||
/// </summary> | ||
internal static partial class IntrinsicMethods | ||
{ | ||
[IntrinsicMethod("Mosa.Runtime.Intrinsic::GetBootOptions")] | ||
private static void GetBootOptions(Context context, TransformContext transformContext) | ||
{ | ||
context.SetInstruction(transformContext.MoveInstruction, context.Result, Operand.CreateLabel(Metadata.BootOptions, transformContext.Is32BitPlatform)); | ||
} | ||
} |
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
16 changes: 0 additions & 16 deletions
16
Source/Mosa.Compiler.Framework/Linker/Elf/Dwarf/WriterExtensions.cs
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,91 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
using Mosa.Runtime; | ||
|
||
namespace Mosa.Kernel.BareMetal | ||
{ | ||
public static class BootOptions | ||
public class BootOptions | ||
{ | ||
// FUTURE | ||
private static Pointer Options; | ||
|
||
public static void Setup() | ||
{ | ||
Options = Intrinsic.GetBootOptions(); | ||
|
||
var debug = GetValue("Debug.Option"); | ||
|
||
if (debug != null) | ||
{ | ||
Debug.WriteLine("Debug.Option: ", debug); | ||
} | ||
else | ||
{ | ||
Debug.WriteLine("Debug.Option: None"); | ||
} | ||
} | ||
|
||
public static string GetValue(string key) | ||
{ | ||
if (Options.IsNull) | ||
return null; | ||
|
||
var keylen = key.Length; | ||
|
||
var parsekey = true; | ||
var parsematch = true; | ||
var parsevalue = false; | ||
var start = 0; | ||
var len = 0; | ||
|
||
for (var at = 0; ; at++) | ||
{ | ||
var c = Options.Load8(at); | ||
|
||
if (c == 0) | ||
break; | ||
|
||
if (c == ',') | ||
{ | ||
if (parsematch) | ||
break; | ||
|
||
parsekey = true; | ||
parsevalue = false; | ||
parsematch = true; | ||
start = 0; | ||
len = 0; | ||
} | ||
else if (c == '=') | ||
{ | ||
parsematch = parsematch && (len == keylen); | ||
parsekey = false; | ||
parsevalue = true; | ||
start = at + 1; | ||
len = 0; | ||
} | ||
else if (parsekey) | ||
{ | ||
if (len >= keylen || c != (byte)key[len]) | ||
parsematch = false; | ||
|
||
len++; | ||
} | ||
else if (parsevalue) | ||
{ | ||
len++; | ||
} | ||
} | ||
|
||
if (!parsematch) | ||
return null; | ||
|
||
if (len == 0) | ||
return string.Empty; | ||
|
||
public static bool EnableVirtualMemory; | ||
public static bool EnableMinimalBoot; | ||
public static bool EnableDebugOutput; | ||
unsafe | ||
{ | ||
return new string((sbyte*)Options, start, len); | ||
} | ||
} | ||
} | ||
} |
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,13 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
namespace Mosa.Kernel.BareMetal | ||
{ | ||
public static class BootSettings | ||
{ | ||
// FUTURE | ||
|
||
public static bool EnableVirtualMemory; | ||
public static bool EnableMinimalBoot; | ||
public static bool EnableDebugOutput; | ||
} | ||
} |
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.