Skip to content

Commit

Permalink
- WIP (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil committed Aug 13, 2023
1 parent 5a3cb20 commit ba2e8bd
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Source/Docs/command-line-arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Below are the command line arguments available:
-output-hash,CompilerDebug.PostLinkHashFile,%DEFAULT%
-check,CompilerDebug.FullCheckMode,true
-asm,CompilerDebug.AsmFile,%DEFAULT%
-map,CompilerDebug.AsmFile,%DEFAULT%
-map,CompilerDebug.MapFile,%DEFAULT%

Compiler - X86:
-interrupt-method,X86.InterruptMethodName,{value}
Expand Down
5 changes: 2 additions & 3 deletions Source/Mosa.BareMetal.HelloWorld/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ public static void EntryPoint()
Console.ForegroundColor = ConsoleColor.White;
Console.Clear();

Debug.WriteLine("##PASS##");

AppManager.Execute("ShowISA");
AppManager.Execute("ShowPCI");
AppManager.Execute("ShowDisks");
AppManager.Execute("ShowFS");

Debug.WriteLine("##PASS##");

AppManager.Execute("Shell");

Console.WriteLine("User has decided to exit out of shell.");
Expand Down
24 changes: 19 additions & 5 deletions Source/Mosa.Kernel.BareMetal/BootOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ namespace Mosa.Kernel.BareMetal
{
public class BootOptions
{
private static Pointer Options;
private static Pointer StaticOptions;
private static Pointer RuntimeOptions;

public static void Setup()
{
Options = Intrinsic.GetBootOptions();
StaticOptions = Intrinsic.GetBootOptions();
RuntimeOptions = Multiboot.IsAvailable ? Multiboot.MultibootV1.CommandLineAddress : Pointer.Zero;

var debug = GetValue("Debug.Option");

Expand All @@ -26,7 +28,19 @@ public static void Setup()

public static string GetValue(string key)
{
if (Options.IsNull)
var result = GetValue(RuntimeOptions, key);

if (result != null)
{
result = GetValue(StaticOptions, key);
}

return result;
}

private static string GetValue(Pointer options, string key)
{
if (options.IsNull)
return null;

var keylen = key.Length;
Expand All @@ -39,7 +53,7 @@ public static string GetValue(string key)

for (var at = 0; ; at++)
{
var c = Options.Load8(at);
var c = options.Load8(at);

if (c == 0)
break;
Expand Down Expand Up @@ -84,7 +98,7 @@ public static string GetValue(string key)

unsafe
{
return new string((sbyte*)Options, start, len);
return new string((sbyte*)options, start, len);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ private struct MultiBootInfoOffset
public const byte VbeInterfaceLength = 92;
}

public struct Flag
{
public const byte Cmdline = 1 << 2;
}

#endregion Multiboot Info Offsets

public MultibootV1(Pointer entry) => Entry = entry;

public bool HasCmdline => IsAvailable && (Flags & Flag.Cmdline) == 1;

/// <summary>
/// Gets a value indicating whether multiboot v1 is available.
/// </summary>
Expand Down Expand Up @@ -75,7 +82,7 @@ private struct MultiBootInfoOffset
/// <summary>
/// Gets the command line address.
/// </summary>
public Pointer CommandLineAddress => Entry.LoadPointer(MultiBootInfoOffset.CommandLine);
public Pointer CommandLineAddress => HasCmdline ? Entry.LoadPointer(MultiBootInfoOffset.CommandLine) : Pointer.Zero;

/// <summary>
/// Gets the module count.
Expand Down
1 change: 1 addition & 0 deletions Source/Mosa.Utility.Configuration/CommandLineArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ private static List<Argument> GetMap()

new Argument { Name = "-osname", Setting = Name.OS_Name},
new Argument { Name = "-bootoptions", Setting = Name.OS_BootOptions},
new Argument { Name = "-bootloader-timeout", Setting = Name.BootLoaderTimeout},

new Argument { Name = "-launch-gdb", Setting = Name.Launcher_GDB, Value="true"},
new Argument { Name = "-launch-debugger", Setting = Name.Launcher_Debugger, Value="true"},
Expand Down
6 changes: 6 additions & 0 deletions Source/Mosa.Utility.Configuration/MOSASettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,12 @@ public string OSBootOptions
set => Settings.SetValue(Name.OS_BootOptions, value);
}

public int BootLoaderTimeout
{
get => Settings.GetValue(Name.BootLoaderTimeout, 0);
set => Settings.SetValue(Name.BootLoaderTimeout, value);
}

#endregion Properties

public MosaSettings()
Expand Down
2 changes: 2 additions & 0 deletions Source/Mosa.Utility.Configuration/Name.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public static class Name
public const string OS_Name = "OS.Name";
public const string OS_BootOptions = "OS.BootOptions";

public const string BootLoaderTimeout = "BootLoader.Timeout";

public const string SearchPaths = "SearchPaths";
public const string TemporaryFolder = "TemporaryFolder";
public const string UnitTest_Connection_MaxAttempts = "UnitTest.Connection.MaxAttempts";
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Utility.Launcher/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private void CreateDiskImage(string imagefile)

private byte[] GetLimineCFG()
{
return Encoding.ASCII.GetBytes($"TIMEOUT=0\nINTERFACE_RESOLUTION=640x480\nINTERFACE_BRANDING=Managed Operating System Alliance\n:{MosaSettings.OSName}\nPROTOCOL={(MosaSettings.MultibootVersion == "v2" ? "multiboot2" : "multiboot1")}\nKERNEL_PATH=boot:///kernel.bin");
return Encoding.ASCII.GetBytes($"TIMEOUT={MosaSettings.BootLoaderTimeout}\nINTERFACE_RESOLUTION=640x480\nINTERFACE_BRANDING=Managed Operating System Alliance\n:{MosaSettings.OSName}\nPROTOCOL={(MosaSettings.MultibootVersion == "v2" ? "multiboot2" : "multiboot1")}\nKERNEL_PATH=boot:///kernel.bin");
}

private void CreateVMDK(string source)
Expand Down

0 comments on commit ba2e8bd

Please sign in to comment.