Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mosa.Utility.Launcher: bug fixes and behavioral changes #1217

Merged
merged 5 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Demos/Run-BareMetal.CoolWorld.x86.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
cd ../bin
./Mosa.Tool.Launcher.Console -autostart -oMax -output-asm -output-debug -output-hash -vmware-svga -include Include Mosa.BareMetal.CoolWorld.x86.dll
AnErrupTion marked this conversation as resolved.
Show resolved Hide resolved
./Mosa.Tool.Launcher -autostart -oMax -output-asm -output-debug -output-hash -vmware-svga -include Include Mosa.BareMetal.CoolWorld.x86.dll
2 changes: 1 addition & 1 deletion Demos/Run-BareMetal.HelloWorld.x86.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
cd ../bin
./Mosa.Tool.Launcher.Console -autostart -oMax -output-asm -output-debug -output-hash Mosa.BareMetal.HelloWorld.x86.dll
./Mosa.Tool.Launcher -autostart -oMax -output-asm -output-debug -output-hash Mosa.BareMetal.HelloWorld.x86.dll
2 changes: 1 addition & 1 deletion Demos/Run-BareMetal.Starter.x86.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
cd ../bin
./Mosa.Tool.Launcher.Console -autostart -oMax -output-asm -output-debug -output-hash Mosa.BareMetal.Starter.x86.dll
./Mosa.Tool.Launcher -autostart -oMax -output-asm -output-debug -output-hash Mosa.BareMetal.Starter.x86.dll

2 changes: 1 addition & 1 deletion Demos/Run-BareMetal.TestWorld.x86.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
cd ../bin
./Mosa.Tool.Launcher.Console -autostart -oMax -output-asm -output-debug -output-hash Mosa.BareMetal.TestWorld.x86.dll
./Mosa.Tool.Launcher -autostart -oMax -output-asm -output-debug -output-hash Mosa.BareMetal.TestWorld.x86.dll

2 changes: 1 addition & 1 deletion Demos/Run-VMware-BareMetal.CoolWorld.x86.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
cd ../bin
./Mosa.Tool.Launcher.Console -autostart -oMax -output-asm -output-debug -output-hash -vmware -vmdk -include Include Mosa.BareMetal.CoolWorld.x86.dll
./Mosa.Tool.Launcher -autostart -oMax -output-asm -output-debug -output-hash -vmware -vmdk -include Include Mosa.BareMetal.CoolWorld.x86.dll
2 changes: 1 addition & 1 deletion Demos/Run-VirtualBox-BareMetal.CoolWorld.x86.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
cd ../bin
./Mosa.Tool.Launcher.Console -autostart -oMax -output-asm -output-debug -output-hash -virtualbox -vdi -include Include Mosa.BareMetal.CoolWorld.x86.dll
./Mosa.Tool.Launcher -autostart -oMax -output-asm -output-debug -output-hash -virtualbox -vdi -include Include Mosa.BareMetal.CoolWorld.x86.dll
7 changes: 4 additions & 3 deletions Source/Docs/command-line-arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ Below are the command line arguments available:
-timeout,Emulator.MaxRuntime,{value}
-debug,Launcher.Serial,true
-debug,OS.BootOptions,bootoptions=serialdebug

-acceleration,Emulator.Acceleration,true

Launcher - Emulator - Qemu & VMWare:
-vmware-svga,Emulator.SVGA,vmware
-virtio-vga,Emulator.SVGA,virtio
-vmware-svga,Emulator.Graphics,vmware
-virtio-vga,Emulator.Graphics,virtio

Launcher - Image:
-image,Image.ImageFile,{value}
Expand Down
5 changes: 4 additions & 1 deletion Source/Docs/settings-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,14 @@ Emulator Settings
Emulator,"Type of Emulator QEMU, VMware, Bochs"
Emulator.Memory,Amount of memory for the virtual machine in MB
Emulator.Display,"If true, show the video display"
Emulator.SVGA,"SVGA mode: std, cirrus, vbe, virtio or vmware"
Emulator.Graphics,"Graphics device: std, cirrus, vbe, virtio or vmware"
Emulator.MaxRuntime,Maximum runtime of the virtual machine in seconds (future)
Emulator.GDB,"If true, enables GDB within emulator"
Emulator.Serial,"Serial Emulation type None, Pipe, TCPServer, TCPClient"
Emulator.Serial.Host,Serial Host Name or IP address
Emulator.Serial.Port,Serial Port
Emulator.Serial.Pipe,Serial Pipename
Emulator.Acceleration,Enables CPU hardware acceleration on the emulator, if available

GDB Settings
------------
Expand Down Expand Up @@ -202,6 +203,8 @@ Application Location Settings
:widths: 50, 200

AppLocation.Bochs,Location of the BOCHS application
AppLocation.Bochs.BIOS,Location of the BOCHS BIOS
AppLocation.Bochs.VGABIOS,Location of the BOCHS VGA BIOS
AppLocation.QemuX86,Location of the QEMU application for x86 (i386)
AppLocation.QemuX64,Location of the QEMU application for x64
AppLocation.QemuARM32,Location of the QEMU application for ARM32
Expand Down
4 changes: 4 additions & 0 deletions Source/Mosa.Tool.Launcher/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@
<Label FontSize="14" Name="qemuImgPathLbl" Margin="165, -23, 0, 0">No path specified</Label>
<Label FontSize="14">Bochs:</Label>
<Label FontSize="14" Name="bochsPathLbl" Margin="165, -23, 0, 0">No path specified</Label>
<Label FontSize="14">Bochs BIOS:</Label>
<Label FontSize="14" Name="bochsBiosPathLbl" Margin="165, -23, 0, 0">No path specified</Label>
<Label FontSize="14">Bochs VGA BIOS:</Label>
<Label FontSize="14" Name="bochsVgaBiosPathLbl" Margin="165, -23, 0, 0">No path specified</Label>
<Label FontSize="14">VMWare:</Label>
<Label FontSize="14" Name="vmwarePathLbl" Margin="165, -23, 0, 0">No path specified</Label>
<Label FontSize="14">VirtualBox:</Label>
Expand Down
2 changes: 2 additions & 0 deletions Source/Mosa.Tool.Launcher/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ private void UpdateInterfaceAppLocations()
qemuEdk2ARMPathLbl.Content = MosaSettings.QemuEdk2ARM32;
qemuImgPathLbl.Content = MosaSettings.QemuImgApp;
bochsPathLbl.Content = MosaSettings.BochsApp;
bochsBiosPathLbl.Content = MosaSettings.BochsBIOS;
bochsVgaBiosPathLbl.Content = MosaSettings.BochsVGABIOS;
vmwarePathLbl.Content = string.IsNullOrEmpty(MosaSettings.VmwarePlayerApp) ? MosaSettings.VmwareWorkstationApp : MosaSettings.VmwarePlayerApp;
vboxPathLbl.Content = MosaSettings.VirtualBoxApp;
mkisofsPathLbl.Content = MosaSettings.MkisofsApp;
Expand Down
60 changes: 60 additions & 0 deletions Source/Mosa.Utility.Configuration/AppLocationsSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public static void GetAppLocations(MosaSettings mosaSettings)
mosaSettings.QemuEdk2ARM64 = FindQemuEDK2ARM64();
mosaSettings.QemuImgApp = FindQemuImg();
mosaSettings.BochsApp = FindBochs();
mosaSettings.BochsBIOS = FindBochsBIOS();
mosaSettings.BochsVGABIOS = FindBochsVGABIOS();
mosaSettings.VmwarePlayerApp = FindVmwarePlayer();
mosaSettings.VmwareWorkstationApp = FindVmwareWorkstation();
mosaSettings.VirtualBoxApp = FindVirtualBox();
Expand Down Expand Up @@ -227,6 +229,64 @@ private static string FindBochs()
: TryFind("bochs", LinuxDirectories);
}

private static string FindBochsBIOS()
{
return
IsWindows ? TryFind("BIOS-bochs-latest",
new string[] {
@"%ProgramFiles%\Bochs-2.6.9",
@"%ProgramFiles(x86)%\Bochs-2.6.9",
@"%ProgramFiles%\Bochs-2.6.8",
@"%ProgramFiles(x86)%\Bochs-2.6.8",
@"%ProgramFiles%\Bochs-2.6.5",
@"%ProgramFiles(x86)%\Bochs-2.6.5",
@"%ProgramFiles%\Bochs-2.6.2",
@"%ProgramFiles(x86)%\Bochs-2.6.2",
@"%ProgramFiles%\Bochs-2.7",
@"%ProgramFiles(x86)%\Bochs-2.7",

@"%CURRENT%\..\Tools\Bochs",
@"%CURRENT%\Tools\Bochs",

@"%APPDIR%\Tools\Bochs",
@"%APPDIR%\..\Tools\Bochs"
})
: TryFind("BIOS-bochs-latest",
new string[] {
"/usr/share/bochs",
"/opt/homebrew/share/bochs/"
});
}

private static string FindBochsVGABIOS()
{
return
IsWindows ? TryFind("VGABIOS-lgpl-latest",
new string[] {
@"%ProgramFiles%\Bochs-2.6.9",
@"%ProgramFiles(x86)%\Bochs-2.6.9",
@"%ProgramFiles%\Bochs-2.6.8",
@"%ProgramFiles(x86)%\Bochs-2.6.8",
@"%ProgramFiles%\Bochs-2.6.5",
@"%ProgramFiles(x86)%\Bochs-2.6.5",
@"%ProgramFiles%\Bochs-2.6.2",
@"%ProgramFiles(x86)%\Bochs-2.6.2",
@"%ProgramFiles%\Bochs-2.7",
@"%ProgramFiles(x86)%\Bochs-2.7",

@"%CURRENT%\..\Tools\Bochs",
@"%CURRENT%\Tools\Bochs",

@"%APPDIR%\Tools\Bochs",
@"%APPDIR%\..\Tools\Bochs"
})
: TryFind("VGABIOS-lgpl-latest",
new string[] {
"/usr/share/bochs",
"/opt/homebrew/share/bochs/"
});
}

private static string FindQemuImg()
{
return
Expand Down
6 changes: 4 additions & 2 deletions Source/Mosa.Utility.Configuration/CommandLineArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ private static List<Argument> GetMap()
new Argument { Name = "-video-width", Setting = Name.Multiboot_Video_Width},
new Argument { Name = "-video-height", Setting = Name.Multiboot_Video_Height},

new Argument { Name = "-vmware-svga", Setting = Name.Emulator_SVGA, Value = "vmware"},
new Argument { Name = "-virtio-vga", Setting = Name.Emulator_SVGA, Value = "virtio"},
new Argument { Name = "-vmware-svga", Setting = Name.Emulator_Graphics, Value = "vmware"},
new Argument { Name = "-virtio-vga", Setting = Name.Emulator_Graphics, Value = "virtio"},

new Argument { Name = "-acceleration", Setting = Name.Emulator_Acceleration, Value = "true"},

new Argument { Name = "-gdb-port", Setting = Name.GDB_Port},
new Argument { Name = "-gdb-host", Setting = Name.GDB_Host},
Expand Down
24 changes: 21 additions & 3 deletions Source/Mosa.Utility.Configuration/MOSASettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ public string BochsApp
set => Settings.SetValue(Name.AppLocation_Bochs, value);
}

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

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

public string CompileTimeFile
{
get => Settings.GetValue(Name.CompilerDebug_CompileTimeFile, null);
Expand Down Expand Up @@ -121,10 +133,10 @@ public string EmulatorSerial
set => Settings.SetValue(Name.Emulator_Serial, value);
}

public string EmulatorSVGA
public string EmulatorGraphics
{
get => Settings.GetValue(Name.Emulator_SVGA, "std");
set => Settings.SetValue(Name.Emulator_SVGA, value);
get => Settings.GetValue(Name.Emulator_Graphics, "std");
set => Settings.SetValue(Name.Emulator_Graphics, value);
}

public string EmulatorSerialHost
Expand All @@ -145,6 +157,12 @@ public ushort EmulatorSerialPort
set => Settings.SetValue(Name.Emulator_Serial_Port, value);
}

public bool EmulatorAcceleration
{
get => Settings.GetValue(Name.Emulator_Acceleration, false);
set => Settings.SetValue(Name.Emulator_Acceleration, value);
}

public string FileSystem
{
get => Settings.GetValue(Name.Image_FileSystem, null);
Expand Down
5 changes: 4 additions & 1 deletion Source/Mosa.Utility.Configuration/Name.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace Mosa.Utility.Configuration;
public static class Name
{
public const string AppLocation_Bochs = "AppLocation.Bochs";
public const string AppLocation_Bochs_BIOS = "AppLocation.Bochs.BIOS";
AnErrupTion marked this conversation as resolved.
Show resolved Hide resolved
public const string AppLocation_Bochs_VGABIOS = "AppLocation.Bochs.VGABIOS";
public const string AppLocation_GDB = "AppLocation.GDB";
public const string AppLocation_Mkisofs = "AppLocation.Mkisofs";
public const string AppLocation_Ndisasm = "AppLocation.Ndisasm";
Expand Down Expand Up @@ -60,8 +62,9 @@ public static class Name
public const string Emulator_Serial_Host = "Emulator.Serial.Host";
public const string Emulator_Serial_Pipe = "Emulator.Serial.Pipe";
public const string Emulator_Serial_Port = "Emulator.Serial.Port";
public const string Emulator_Graphics = "Emulator.Graphics";
AnErrupTion marked this conversation as resolved.
Show resolved Hide resolved
public const string Emulator_Acceleration = "Emulator.Acceleration";
AnErrupTion marked this conversation as resolved.
Show resolved Hide resolved

public const string Emulator_SVGA = "Emulator.SVGA";
public const string Explorer_DebugDiagnostic = "Explorer.DebugDiagnostic";
public const string Explorer_Filter = "Explorer.Filter";
public const string Explorer_Start = "Explorer.Start";
Expand Down
66 changes: 30 additions & 36 deletions Source/Mosa.Utility.Launcher/BaseLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System.Diagnostics;
using System.Reflection;
using System.Resources;
using Mosa.Compiler.Framework;
using Mosa.Utility.Configuration;

Expand Down Expand Up @@ -41,46 +42,37 @@ protected virtual void OutputEvent(string status)

protected static byte[] GetResource(string path, string name)
{
var newname = path.Replace(".", "._").Replace(@"\", "._").Replace("/", "._").Replace("-", "_") + "." + name;
return GetResource(newname);
}

protected static byte[] GetResource(string name)
{
var assembly = Assembly.GetExecutingAssembly();
var stream = assembly.GetManifestResourceStream("Mosa.Utility.Launcher.Resources." + name);
var binary = new BinaryReader(stream);
return binary.ReadBytes((int)stream.Length);
}

protected static string Quote(string location)
{
return '"' + location + '"';
return GetResource($"{path
.Replace(".", "._")
.Replace(@"\", "._")
.Replace("/", "._")
.Replace("-", "_")}.{name}");
}

protected Process CreateApplicationProcess(string app, string args)
{
OutputStatus($"Starting Application: {app}");
OutputStatus($"Arguments: {args}");

var process = new Process();

process.StartInfo.FileName = app;
process.StartInfo.Arguments = args;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = false;
process.StartInfo.RedirectStandardError = false;
process.StartInfo.CreateNoWindow = true;
var startInfo = new ProcessStartInfo
{
FileName = app,
Arguments = args,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = false,
RedirectStandardError = false
};

return process;
return new Process { StartInfo = startInfo };
}

protected Process LaunchApplication(string app, string args)
{
OutputStatus($"Launching Application: {app}");
OutputStatus($"Arguments: {args}");

var start = new ProcessStartInfo
var startInfo = new ProcessStartInfo
{
FileName = app,
Arguments = args,
Expand All @@ -90,15 +82,15 @@ protected Process LaunchApplication(string app, string args)
RedirectStandardError = true
};

return Process.Start(start);
return Process.Start(startInfo);
}

protected Process LaunchConsoleApplication(string app, string args)
{
OutputStatus($"Launching Console Application: {app}");
OutputStatus($"Arguments: {args}");

var start = new ProcessStartInfo
var startInfo = new ProcessStartInfo
{
FileName = app,
Arguments = args,
Expand All @@ -108,18 +100,17 @@ protected Process LaunchConsoleApplication(string app, string args)
RedirectStandardError = false
};

return Process.Start(start);
return Process.Start(startInfo);
}

protected string GetOutput(Process process)
protected static string GetOutput(Process process)
{
var output = process.StandardOutput.ReadToEnd();

process.WaitForExit();

var output = process.StandardOutput.ReadToEnd();
var error = process.StandardError.ReadToEnd();

return output + error;
return $"{output}{error}";
}

protected Process LaunchApplicationWithOutput(string app, string arg)
Expand All @@ -132,11 +123,14 @@ protected Process LaunchApplicationWithOutput(string app, string arg)
return process;
}

protected string NullToEmpty(string value)
private static byte[] GetResource(string name)
{
if (string.IsNullOrWhiteSpace(value))
return string.Empty;
var assembly = Assembly.GetExecutingAssembly();
var stream = assembly.GetManifestResourceStream($"Mosa.Utility.Launcher.Resources.{name}");
if (stream == null)
throw new MissingManifestResourceException($"Cannot find resource: {name}");

return value;
var binary = new BinaryReader(stream);
return binary.ReadBytes((int)stream.Length);
}
}
Loading
Loading