Skip to content

Commit

Permalink
Updated Settings (#1254)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil authored Dec 25, 2024
1 parent 30e8832 commit 66d6d8a
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 59 deletions.
2 changes: 0 additions & 2 deletions Source/Docs/command-line-arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ Below are the command line arguments available:

-blocks,Image.DiskBlocks,{value}
-volume-label,Image.VolumeLabel,{value}
-mbr,Image.MasterBootRecordFile,{value}
-boot,Image.BootBlockFile,{value}

-include,Image.FileSystem.RootInclude,{value}

Expand Down
2 changes: 2 additions & 0 deletions Source/Docs/settings-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ Image Settings
Image.Destination,Destination directory of the image file
Image.ImageFile,Filename of the image file
Image.FileSystem.RootInclude,Include files in specified directory
Image.DiskBlocks,Number of blocks in image (0=automatic)
Image.VolumeLabel,Volume Label

Emulator Settings
-----------------
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Utility.BootImage/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static void Create(BootImageOptions options)
},
FloppyMedia = false,
VolumeLabel = options.VolumeLabel,
SerialID = new byte[] { 0x01, 0x02, 0x03, 0x04 },
SerialID = [0x01, 0x02, 0x03, 0x04],
SectorsPerTrack = diskGeometry.SectorsPerTrack,
NumberOfHeads = diskGeometry.Heads,
HiddenSectors = diskGeometry.SectorsPerTrack,
Expand Down
3 changes: 2 additions & 1 deletion Source/Mosa.Utility.BootImage/Limine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace Mosa.Utility.BootImage;

//https://github.com/limine-bootloader/limine/blob/v4.0-binary/limine-deploy.c
// https://github.com/limine-bootloader/limine/blob/v4.0-binary/limine-deploy.c

public static class Limine
{
private static readonly byte[] BootloaderImg =
Expand Down
7 changes: 3 additions & 4 deletions Source/Mosa.Utility.Configuration/CommandLineArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ private static List<Argument> GetMap()

// Compiler - Debug:
new Argument { Name = "-inline-exclude", Setting = Name.Optimizations_Inline_Exclude, IsList = true},
new Argument { Name = "-test-filter", Setting = Name.CompilerDebug_TestFilter},
new Argument { Name = "-check", Setting = Name.CompilerDebug_FullCheckMode, Value = "true"},

new Argument { Name = "-interrupt-method", Setting = Name.X86_InterruptMethodName},
Expand Down Expand Up @@ -134,8 +133,8 @@ private static List<Argument> GetMap()

new Argument { Name = "-blocks", Setting = Name.Image_DiskBlocks},
new Argument { Name = "-volume-label", Setting = Name.Image_VolumeLabel},
new Argument { Name = "-mbr", Setting = Name.Image_MasterBootRecordFile},
new Argument { Name = "-boot", Setting = Name.Image_BootBlockFile},
//new Argument { Name = "-mbr", Setting = Name.Image_MasterBootRecordFile},
//new Argument { Name = "-boot", Setting = Name.Image_BootBlockFile},

new Argument { Name = "-include", Setting = Name.Image_FileSystem_RootInclude },

Expand Down Expand Up @@ -171,7 +170,7 @@ private static List<Argument> GetMap()
new Argument { Name = "-launch-debugger", Setting = Name.Launcher_Debugger, Value = "true"},

new Argument { Name = "-output-serial-connection", Setting = Name.Launcher_Serial},
new Argument { Name = "-output-serial-file", Setting = Name.Launcher_Serial_File},
//new Argument { Name = "-output-serial-file", Setting = Name.Launcher_Serial_File},
new Argument { Name = "-debug", Setting = Name.Launcher_Serial, Value = "true"},
new Argument { Name = "-debug", Setting = Name.OS_BootOptions, Value = "bootoptions=serialdebug"},

Expand Down
22 changes: 16 additions & 6 deletions Source/Mosa.Utility.Configuration/MOSASettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ public string ImageFormat
set => Settings.SetValue(Name.Image_Format, value);
}

public string VolumeLabel
{
get => Settings.GetValue(Name.Image_VolumeLabel, null);
set => Settings.SetValue(Name.Image_VolumeLabel, value);
}

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

public string InlinedFile
{
get => Settings.GetValue(Name.CompilerDebug_InlinedFile, null);
Expand Down Expand Up @@ -283,12 +295,6 @@ public string CounterFilter
set => Settings.SetValue(Name.CompilerDebug_CounterFilter, value);
}

public string TestFilter
{
get => Settings.GetValue(Name.CompilerDebug_TestFilter, null);
set => Settings.SetValue(Name.CompilerDebug_TestFilter, value);
}

public int MaxThreads
{
get => Settings.GetValue(Name.Compiler_Multithreading_MaxThreads, 0);
Expand Down Expand Up @@ -821,6 +827,8 @@ public void SetDefaultSettings()
ImageFile = "%DEFAULT%";

OSName = "MOSA";
VolumeLabel = "MOSA";
DiskBlocks = 0;

MaxErrors = Constant.MaxErrors;
ConnectionTimeOut = Constant.ConnectionTimeOut;
Expand Down Expand Up @@ -876,6 +884,8 @@ public void AdjustSettings()

if (InlineAggressiveMaximum < 0)
InlineAggressiveMaximum = 0;

VolumeLabel ??= OSName;
}

public void ResolveDefaults()
Expand Down
7 changes: 3 additions & 4 deletions Source/Mosa.Utility.Configuration/Name.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public static class Name
public const string CompilerDebug_PreLinkHashFile = "CompilerDebug.PreLinkHashFile";
public const string CompilerDebug_Statistics = "CompilerDebug.Statistics";
public const string CompilerDebug_CounterFilter = "CompilerDebug.CounterFilter";
public const string CompilerDebug_TestFilter = "CompilerDebug.TestFilter";
public const string Debugger_BreakpointFile = "Debugger.BreakpointFile";
public const string Debugger_WatchFile = "Debugger.WatchFile";
public const string DefaultFolder = "DefaultFolder";
Expand Down Expand Up @@ -130,9 +129,9 @@ public static class Name

public const string Image_DiskBlocks = "Image.DiskBlocks";
public const string Image_VolumeLabel = "Image.VolumeLabel";
public const string Image_MasterBootRecordFile = "Image.MasterBootRecordFile";
public const string Image_BootBlockFile = "Image.BootBlockFile";
public const string Launcher_Serial_File = "Launcher.Serial_File";
//public const string Image_MasterBootRecordFile = "Image.MasterBootRecordFile";
//public const string Image_BootBlockFile = "Image.BootBlockFile";
//public const string Launcher_Serial_File = "Launcher.Serial_File";

public const string X86_InterruptMethodName = "X86.InterruptMethodName";
}
84 changes: 43 additions & 41 deletions Source/Mosa.Utility.Launcher/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,24 @@ private void BuildImage()
switch (MosaSettings.ImageFormat)
{
case "vmdk":
{
var imageFile = Path.Combine(MosaSettings.TemporaryFolder, $"{Path.GetFileNameWithoutExtension(MosaSettings.ImageFile)}.img");
CreateDiskImage(imageFile);
CreateVMDK(imageFile);
break;
}
{
var imageFile = Path.Combine(MosaSettings.TemporaryFolder, $"{Path.GetFileNameWithoutExtension(MosaSettings.ImageFile)}.img");
CreateDiskImage(imageFile);
CreateVMDK(imageFile);
break;
}
case "vdi":
{
var imageFile = Path.Combine(MosaSettings.TemporaryFolder, $"{Path.GetFileNameWithoutExtension(MosaSettings.ImageFile)}.img");
CreateDiskImage(imageFile);
CreateVDI(imageFile);
break;
}
{
var imageFile = Path.Combine(MosaSettings.TemporaryFolder, $"{Path.GetFileNameWithoutExtension(MosaSettings.ImageFile)}.img");
CreateDiskImage(imageFile);
CreateVDI(imageFile);
break;
}
default:
{
CreateDiskImage(MosaSettings.ImageFile);
break;
}
{
CreateDiskImage(MosaSettings.ImageFile);
break;
}
}
}

Expand All @@ -142,6 +142,7 @@ private void AddCounters(string data)
private void CreateDiskImage(string imageFile)
{
var bootImageOptions = new BootImageOptions();

bootImageOptions.IncludeFiles.Add(new IncludeFile("limine.cfg", GetLimineCFG()));
bootImageOptions.IncludeFiles.Add(new IncludeFile("limine.sys", GetResource("limine", "limine.sys")));
bootImageOptions.IncludeFiles.Add(new IncludeFile(MosaSettings.OutputFile, "kernel.bin"));
Expand All @@ -159,7 +160,8 @@ private void CreateDiskImage(string imageFile)
}
}

bootImageOptions.VolumeLabel = MosaSettings.OSName;
bootImageOptions.VolumeLabel = MosaSettings.VolumeLabel;
bootImageOptions.BlockCount = (uint)MosaSettings.DiskBlocks;
bootImageOptions.DiskImageFileName = imageFile;
bootImageOptions.ImageFirmware = MosaSettings.ImageFirmware switch
{
Expand Down Expand Up @@ -187,13 +189,13 @@ private void CreateDiskImage(string imageFile)
}

private byte[] GetLimineCFG() => Encoding.ASCII.GetBytes($"""
TIMEOUT={MosaSettings.BootLoaderTimeout}
INTERFACE_RESOLUTION=640x480
INTERFACE_BRANDING=Managed Operating System Alliance
:{MosaSettings.OSName}
PROTOCOL=multiboot2
KERNEL_PATH=boot:///kernel.bin
""");
TIMEOUT={MosaSettings.BootLoaderTimeout}
INTERFACE_RESOLUTION=640x480
INTERFACE_BRANDING=Managed Operating System Alliance
:{MosaSettings.OSName}
PROTOCOL=multiboot2
KERNEL_PATH=boot:///kernel.bin
""");

private void CreateVMDK(string source)
=> LaunchApplicationWithOutput(MosaSettings.QemuImgApp, $"convert -f raw -O vmdk \"{source}\" \"{MosaSettings.ImageFile}\"");
Expand Down Expand Up @@ -266,26 +268,26 @@ private void NotifyEvent(CompilerEvent compilerEvent, string message, int thread
switch (compilerEvent)
{
case CompilerEvent.Exception:
{
var status = $"[Exception] {message}";
{
var status = $"[Exception] {message}";

OutputStatus(status);
break;
}
OutputStatus(status);
break;
}
case CompilerEvent.CompilerStart or CompilerEvent.CompilerEnd or CompilerEvent.CompilingMethodsStart or CompilerEvent.CompilingMethodsCompleted or CompilerEvent.InlineMethodsScheduled or CompilerEvent.LinkingStart or CompilerEvent.LinkingEnd or CompilerEvent.Warning or CompilerEvent.Error:
{
var status = compilerEvent.ToText();
if (!string.IsNullOrEmpty(message))
status += $" => {message}";

OutputStatus(status);
break;
}
{
var status = compilerEvent.ToText();
if (!string.IsNullOrEmpty(message))
status += $" => {message}";

OutputStatus(status);
break;
}
case CompilerEvent.Counter:
{
AddCounters(message);
break;
}
{
AddCounters(message);
break;
}
}
}
}

0 comments on commit 66d6d8a

Please sign in to comment.