From 7ac45122f59839868a7090303417a6299bf32e52 Mon Sep 17 00:00:00 2001 From: Phil Date: Sat, 2 Dec 2023 11:22:38 -0800 Subject: [PATCH] - WIP --- .../Mosa.BareMetal.HelloWorld.ARM32/Boot.cs | 5 ++ .../Mosa.BareMetal.HelloWorld.ARM32.csproj | 1 + Source/Mosa.Compiler.ARM32/Architecture.cs | 12 +++- .../FloatingTweaks/ConvertR4ToU32.cs | 28 +++++++++ .../FloatingTweaks/ConvertR8ToU32.cs | 28 +++++++++ .../FloatingTweaks/ConvertU32ToR8.cs | 28 +++++++++ .../FloatingTweaks/FloatingTweakTransforms.cs | 7 +++ .../FloatingTweaks/RemR4NotSupported.cs | 28 +++++++++ .../FloatingTweaks/RemR8NotSupported.cs | 28 +++++++++ .../PlatformPlug.cs | 3 + .../PlatformPlug.cs | 3 + .../PageFrameAllocator.cs | 17 +----- .../System.Threading/InterlockedPlug.cs | 51 ++++++++++++++++ .../System.Threading/MonitorPlug.cs | 41 +++++++++++++ .../System/Math.CoreCLR.cs | 59 +++++++++++++++++++ .../System/MathF.CoreCLR.cs | 47 +++++++++++++++ Source/Mosa.Tool.Explorer/MainForm.cs | 3 + Source/Mosa.Tool.Launcher/MainWindow.axaml.cs | 1 + .../MOSASettings.cs | 30 ++++------ Source/Mosa.Utility.Launcher/Starter.cs | 2 +- 20 files changed, 388 insertions(+), 34 deletions(-) create mode 100644 Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertR4ToU32.cs create mode 100644 Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertR8ToU32.cs create mode 100644 Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertU32ToR8.cs create mode 100644 Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/RemR4NotSupported.cs create mode 100644 Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/RemR8NotSupported.cs create mode 100644 Source/Mosa.Plug.Korlib.ARM32/System.Threading/InterlockedPlug.cs create mode 100644 Source/Mosa.Plug.Korlib.ARM32/System.Threading/MonitorPlug.cs create mode 100644 Source/Mosa.Plug.Korlib.ARM32/System/Math.CoreCLR.cs create mode 100644 Source/Mosa.Plug.Korlib.ARM32/System/MathF.CoreCLR.cs diff --git a/Source/Mosa.BareMetal.HelloWorld.ARM32/Boot.cs b/Source/Mosa.BareMetal.HelloWorld.ARM32/Boot.cs index 8758f5da43..3956cf548f 100644 --- a/Source/Mosa.BareMetal.HelloWorld.ARM32/Boot.cs +++ b/Source/Mosa.BareMetal.HelloWorld.ARM32/Boot.cs @@ -13,4 +13,9 @@ public static void Main() Program.EntryPoint(); } + + public static void ForceInclude() + { + Mosa.Kernel.BareMetal.ARM32.PlatformPlug.ForceInclude(); + } } diff --git a/Source/Mosa.BareMetal.HelloWorld.ARM32/Mosa.BareMetal.HelloWorld.ARM32.csproj b/Source/Mosa.BareMetal.HelloWorld.ARM32/Mosa.BareMetal.HelloWorld.ARM32.csproj index 4a4831dcc2..dbd05794fb 100644 --- a/Source/Mosa.BareMetal.HelloWorld.ARM32/Mosa.BareMetal.HelloWorld.ARM32.csproj +++ b/Source/Mosa.BareMetal.HelloWorld.ARM32/Mosa.BareMetal.HelloWorld.ARM32.csproj @@ -2,6 +2,7 @@ Exe + Mosa.BareMetal.HelloWorld.ARM32.Boot diff --git a/Source/Mosa.Compiler.ARM32/Architecture.cs b/Source/Mosa.Compiler.ARM32/Architecture.cs index 8a0aac9bb6..613c18ede2 100644 --- a/Source/Mosa.Compiler.ARM32/Architecture.cs +++ b/Source/Mosa.Compiler.ARM32/Architecture.cs @@ -1,8 +1,10 @@ // Copyright (c) MOSA Project. Licensed under the New BSD License. +using Mosa.Compiler.ARM32.CompilerStages; using Mosa.Compiler.ARM32.Stages; using Mosa.Compiler.Common.Exceptions; using Mosa.Compiler.Framework; +using Mosa.Compiler.Framework.CompilerStages; using Mosa.Compiler.Framework.Linker.Elf; using Mosa.Compiler.Framework.Stages; using Mosa.Utility.Configuration; @@ -126,6 +128,14 @@ public override OpcodeEncoder GetOpcodeEncoder() /// The pipeline to extend. public override void ExtendCompilerPipeline(Pipeline pipeline, MosaSettings mosaSettings) { + if (!string.IsNullOrEmpty(mosaSettings.MultibootVersion)) + { + pipeline.InsertAfterFirst( + new MultibootStage() + ); + } + + pipeline.Add(new StartUpStage()); } /// @@ -136,7 +146,7 @@ public override void ExtendCompilerPipeline(Pipeline pipeline public override void ExtendMethodCompilerPipeline(Pipeline pipeline, MosaSettings mosaSettings) { pipeline.InsertBefore( - new Stages.RuntimeCallStage() + new RuntimeCallStage() ); pipeline.InsertAfterLast( diff --git a/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertR4ToU32.cs b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertR4ToU32.cs new file mode 100644 index 0000000000..8ab7550d72 --- /dev/null +++ b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertR4ToU32.cs @@ -0,0 +1,28 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +using Mosa.Compiler.Framework; + +namespace Mosa.Compiler.ARM32.Transforms.FloatingTweaks; + +/// +/// ConvertR4ToU32 +/// +public sealed class ConvertR4ToU32 : BaseTransform +{ + public ConvertR4ToU32() : base(IR.ConvertR4ToU32, TransformType.Manual | TransformType.Transform) + { + } + + public override bool Match(Context context, Transform transform) + { + return true; + } + + public override void Transform(Context context, Transform transform) + { + var result = context.Result; + var operand1 = context.Operand1; + + context.SetInstruction(IR.ConvertR4ToI32, result, operand1); + } +} diff --git a/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertR8ToU32.cs b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertR8ToU32.cs new file mode 100644 index 0000000000..e3216c0997 --- /dev/null +++ b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertR8ToU32.cs @@ -0,0 +1,28 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +using Mosa.Compiler.Framework; + +namespace Mosa.Compiler.ARM32.Transforms.FloatingTweaks; + +/// +/// ConvertR8ToU32 +/// +public sealed class ConvertR8ToU32 : BaseTransform +{ + public ConvertR8ToU32() : base(IR.ConvertR8ToU32, TransformType.Manual | TransformType.Transform) + { + } + + public override bool Match(Context context, Transform transform) + { + return true; + } + + public override void Transform(Context context, Transform transform) + { + var result = context.Result; + var operand1 = context.Operand1; + + context.SetInstruction(IR.ConvertR8ToI32, result, operand1); + } +} diff --git a/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertU32ToR8.cs b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertU32ToR8.cs new file mode 100644 index 0000000000..eea7d802bf --- /dev/null +++ b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/ConvertU32ToR8.cs @@ -0,0 +1,28 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +using Mosa.Compiler.Framework; + +namespace Mosa.Compiler.ARM32.Transforms.FloatingTweaks; + +/// +/// ConvertU32ToR8 +/// +public sealed class ConvertU32ToR8 : BaseTransform +{ + public ConvertU32ToR8() : base(IR.ConvertU32ToR8, TransformType.Manual | TransformType.Transform) + { + } + + public override bool Match(Context context, Transform transform) + { + return true; + } + + public override void Transform(Context context, Transform transform) + { + var result = context.Result; + var operand1 = context.Operand1; + + context.SetInstruction(IR.ConvertI32ToR8, result, operand1); + } +} diff --git a/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/FloatingTweakTransforms.cs b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/FloatingTweakTransforms.cs index 5794676840..48ea913672 100644 --- a/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/FloatingTweakTransforms.cs +++ b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/FloatingTweakTransforms.cs @@ -17,5 +17,12 @@ public static class FloatingTweakTransforms new ConvertR8ToI64(), new ConvertR4ToU64(), new ConvertR8ToU64(), + + new ConvertR4ToU32(), + new ConvertR8ToU32(), + new ConvertU32ToR8(), + + new RemR4NotSupported(), + new RemR8NotSupported(), }; } diff --git a/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/RemR4NotSupported.cs b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/RemR4NotSupported.cs new file mode 100644 index 0000000000..bca6dd16bb --- /dev/null +++ b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/RemR4NotSupported.cs @@ -0,0 +1,28 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +using Mosa.Compiler.Framework; + +namespace Mosa.Compiler.ARM32.Transforms.FloatingTweaks; + +/// +/// RemR4NotSupported +/// +public sealed class RemR4NotSupported : BaseTransform +{ + public RemR4NotSupported() : base(IR.RemR4, TransformType.Manual | TransformType.Transform) + { + } + + public override bool Match(Context context, Transform transform) + { + return true; + } + + public override void Transform(Context context, Transform transform) + { + var result = context.Result; + var operand1 = context.Operand1; + + context.SetInstruction(IR.MoveR4, result, operand1); // NOT SUPPORTED + } +} diff --git a/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/RemR8NotSupported.cs b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/RemR8NotSupported.cs new file mode 100644 index 0000000000..cff42e16f0 --- /dev/null +++ b/Source/Mosa.Compiler.ARM32/Transforms/FloatingTweaks/RemR8NotSupported.cs @@ -0,0 +1,28 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +using Mosa.Compiler.Framework; + +namespace Mosa.Compiler.ARM32.Transforms.FloatingTweaks; + +/// +/// RemR8NotSupported +/// +public sealed class RemR8NotSupported : BaseTransform +{ + public RemR8NotSupported() : base(IR.RemR8, TransformType.Manual | TransformType.Transform) + { + } + + public override bool Match(Context context, Transform transform) + { + return true; + } + + public override void Transform(Context context, Transform transform) + { + var result = context.Result; + var operand1 = context.Operand1; + + context.SetInstruction(IR.MoveR8, result, operand1); // NOT SUPPORTED + } +} diff --git a/Source/Mosa.Kernel.BareMetal.ARM32/PlatformPlug.cs b/Source/Mosa.Kernel.BareMetal.ARM32/PlatformPlug.cs index c28cc4764f..5e15910e8c 100644 --- a/Source/Mosa.Kernel.BareMetal.ARM32/PlatformPlug.cs +++ b/Source/Mosa.Kernel.BareMetal.ARM32/PlatformPlug.cs @@ -12,6 +12,9 @@ public static class PlatformPlug private const uint InitialGCMemoryPoolAddress = 0x03000000; // @ 48MB private const uint InitialGCMemoryPoolSize = 16 * 1024 * 1024; // [Size=16MB] + public static void ForceInclude() + { } + [Plug("Mosa.Kernel.BareMetal.Platform::Initialization")] public static void Initialization() { diff --git a/Source/Mosa.Kernel.BareMetal.ARM64/PlatformPlug.cs b/Source/Mosa.Kernel.BareMetal.ARM64/PlatformPlug.cs index a761e99942..2c1e3b5748 100644 --- a/Source/Mosa.Kernel.BareMetal.ARM64/PlatformPlug.cs +++ b/Source/Mosa.Kernel.BareMetal.ARM64/PlatformPlug.cs @@ -12,6 +12,9 @@ public static class PlatformPlug private const uint InitialGCMemoryPoolAddress = 0x03000000; // @ 48MB private const uint InitialGCMemoryPoolSize = 16 * 1024 * 1024; // [Size=16MB] + public static void ForceInclude() + { } + [Plug("Mosa.Kernel.BareMetal.Platform::Initialization")] public static void Initialization() { diff --git a/Source/Mosa.Kernel.BareMetal/PageFrameAllocator.cs b/Source/Mosa.Kernel.BareMetal/PageFrameAllocator.cs index 7282ff6bfd..07a2428398 100644 --- a/Source/Mosa.Kernel.BareMetal/PageFrameAllocator.cs +++ b/Source/Mosa.Kernel.BareMetal/PageFrameAllocator.cs @@ -98,14 +98,6 @@ public static void Setup() var start = Alignment.AlignDown(entry.StartAddress.ToInt64(), Page.Size); var end = Alignment.AlignUp(entry.EndAddress.ToInt64(), Page.Size); - //Debug.WriteLine(" > reserve"); - //Debug.WriteLineHex(" > start: ", entry.StartAddress.ToInt64()); - //Debug.WriteLineHex(" > end: ", entry.EndAddress.ToInt64()); - //Debug.WriteLine(" > len: ", entry.Size); - - //Debug.WriteLineHex(" > start-aligned: ", start); - //Debug.WriteLineHex(" > end-aligned: ", end); - var pages = (uint)(end - start) / Page.Size; if (pages <= 0) @@ -114,10 +106,6 @@ public static void Setup() var startPage = (uint)(start / Page.Size); var endPage = startPage + pages - 1; - //Debug.WriteLine(" > pages: ", pages); - //Debug.WriteLine(" > startPage: ", startPage); - //Debug.WriteLine(" > endPage: ", endPage); - MinimumReservedPage = Math.Min(MinimumReservedPage, startPage); MaximumReservedPage = Math.Max(MaximumReservedPage, endPage); @@ -133,8 +121,6 @@ public static void Setup() if (endPage > TotalPages) pages = TotalPages - startPage; - //Debug.WriteLine(" > pages2: ", pages); - Debug.WriteLine(" > reserved: ", startPage, " - ", endPage); SetPageBitMapEntry(startPage, pages, false); @@ -357,9 +343,10 @@ private static void ReserveMemory() var region = Platform.GetBootReservedRegion(); SetPageBitMapEntry((uint)(region.Address.ToInt64() / Page.Size), ((uint)region.Size / Page.Size) + 1, false); - // Reserve first 24MB + // Reserve first 24MB (wide enough to cover initial stack and kernel) SetPageBitMapEntry(0, 24 * 1024 * 1024 / Page.Size, false); + // TODO - initial stack // TODO - reserve kernel code + memory } diff --git a/Source/Mosa.Plug.Korlib.ARM32/System.Threading/InterlockedPlug.cs b/Source/Mosa.Plug.Korlib.ARM32/System.Threading/InterlockedPlug.cs new file mode 100644 index 0000000000..22eb8a93f3 --- /dev/null +++ b/Source/Mosa.Plug.Korlib.ARM32/System.Threading/InterlockedPlug.cs @@ -0,0 +1,51 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +using System; +using Mosa.Runtime.Plug; + +namespace Mosa.Plug.Korlib.System.Threading.ARM32; + +public static class InterlockedPlug +{ + [Plug("System.Threading.Interlocked::CompareExchange")] + internal static int CompareExchange(ref int location1, int value, int comparand) + { + //return Native.CmpXChgLoad32(ref location1, value, comparand); + + return 0; + } + + [Plug("System.Threading.Interlocked::Exchange")] + internal static int Exchange(ref int location1, int value) + { + //return Native.XChgLoad32(ref location1, value); + + return 0; + } + + [Plug("System.Threading.Interlocked::ExchangeAdd")] + internal static int ExchangeAdd(ref int location1, int value) + { + //return Native.XAddLoad32(ref location1, value); + + return 0; + } + + [Plug("System.Threading.Interlocked::CompareExchange")] + public static IntPtr CompareExchange(ref IntPtr location1, IntPtr value, IntPtr comparand) + { + //var address = location1.ToInt32(); + //return new IntPtr(CompareExchange(ref address, value.ToInt32(), comparand.ToInt32())); + + return IntPtr.Zero; + } + + [Plug("System.Threading.Interlocked::CompareExchange")] + internal static long CompareExchange(ref long location1, long value, long comparand) + { + //int location = (int)location1; + //return Native.CmpXChgLoad32(location, (int)value, (int)comparand); + + return 0; + } +} diff --git a/Source/Mosa.Plug.Korlib.ARM32/System.Threading/MonitorPlug.cs b/Source/Mosa.Plug.Korlib.ARM32/System.Threading/MonitorPlug.cs new file mode 100644 index 0000000000..bdcf8e8521 --- /dev/null +++ b/Source/Mosa.Plug.Korlib.ARM32/System.Threading/MonitorPlug.cs @@ -0,0 +1,41 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +using System; +using System.Runtime.CompilerServices; +using Mosa.Runtime.Plug; + +namespace Mosa.Plug.Korlib.System.Threading.ARM32; + +public static class MonitorPlug +{ + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [Plug("System.Threading.Monitor::Enter")] + internal static void Enter(Object obj) + { + //var sync = Mosa.Runtime.Internal.GetObjectLockAndStatus(obj); + + //while (Native.CmpXChgLoad32(sync.ToInt32(), 1, 0) != 0) + //{ } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [Plug("System.Threading.Monitor::ReliableEnter")] + internal static void ReliableEnter(Object obj, ref bool lockTaken) + { + //var sync = Mosa.Runtime.Internal.GetObjectLockAndStatus(obj); + + //while (Native.CmpXChgLoad32(sync.ToInt32(), 1, 0) != 0) + //{ } + + lockTaken = true; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [Plug("System.Threading.Monitor::Exit")] + internal static void Exit(Object obj) + { + //var sync = Mosa.Runtime.Internal.GetObjectLockAndStatus(obj); + + //Native.XAddLoad32(sync.ToInt32(), -1); + } +} diff --git a/Source/Mosa.Plug.Korlib.ARM32/System/Math.CoreCLR.cs b/Source/Mosa.Plug.Korlib.ARM32/System/Math.CoreCLR.cs new file mode 100644 index 0000000000..f5b331d503 --- /dev/null +++ b/Source/Mosa.Plug.Korlib.ARM32/System/Math.CoreCLR.cs @@ -0,0 +1,59 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +using Mosa.Runtime.Plug; + +namespace Mosa.Plug.Korlib.System.x86; + +internal static class Math +{ + //[Plug("System.Math::Abs")] + //internal static double Abs(double value) + //{ + // return 0; // TODO + //} + + //[Plug("System.Math::Abs")] + //internal static float Abs(float value) + //{ + // return 0; // TODO + //} + + [Plug("System.Math::Sqrt")] + internal static double Sqrt(double d) + { + //return Native.Sqrtsd(d); + return 0d; + } + + [Plug("System.Math::Ceiling")] + internal static double Ceiling(double d) + { + //return Native.Roundsd2Positive(d); + return 0d; + } + + [Plug("System.Math::Floor")] + internal static double Floor(double d) + { + //return Native.Roundsd2Negative(d); + return 0d; + } + + //[Plug("System.Math::Log")] + //internal static double Log(double d) + //{ + // return 0; // TODO + //} + + //[Plug("System.Math::FMod")] + //internal static double FMod(double x, double y) + //{ + // return 0; // TODO + //} + + //[Plug("System.Math::ModF")] + //internal static unsafe double ModF(double x, double* intptr) + //{ + // return 0; // TODO + //} +} diff --git a/Source/Mosa.Plug.Korlib.ARM32/System/MathF.CoreCLR.cs b/Source/Mosa.Plug.Korlib.ARM32/System/MathF.CoreCLR.cs new file mode 100644 index 0000000000..2e4431cccc --- /dev/null +++ b/Source/Mosa.Plug.Korlib.ARM32/System/MathF.CoreCLR.cs @@ -0,0 +1,47 @@ +// Copyright (c) MOSA Project. Licensed under the New BSD License. + +using Mosa.Runtime.Plug; + +namespace Mosa.Plug.Korlib.System.x86; + +internal static class MathF +{ + [Plug("System.MathF::Ceiling")] + internal static float Ceiling(float s) + { + //return Native.Roundss2Positive(s); + return 0f; + } + + [Plug("System.MathF::Sqrt")] + internal static float Sqrt(float s) + { + //return Native.Sqrtss(s); + return 0f; + } + + [Plug("System.MathF::Floor")] + internal static float Floor(float s) + { + //return Native.Roundss2Negative(s); + return 0f; + } + + //[Plug("System.MathF::Log")] + //internal static float Log(float s) + //{ + // return 0; // TODO + //} + + //[Plug("System.MathF::FMod")] + //internal static float FMod(float x, float y) + //{ + // return 0; // TODO + //} + + //[Plug("System.MathF::ModF")] + //internal static unsafe float ModF(float x, float* intptr) + //{ + // return 0; // TODO + //} +} diff --git a/Source/Mosa.Tool.Explorer/MainForm.cs b/Source/Mosa.Tool.Explorer/MainForm.cs index 7cdc3bcd9e..a0836d5056 100644 --- a/Source/Mosa.Tool.Explorer/MainForm.cs +++ b/Source/Mosa.Tool.Explorer/MainForm.cs @@ -114,7 +114,9 @@ public void LoadArguments(string[] args) if (MosaSettings.SourceFiles == null || MosaSettings.SourceFiles.Count == 0) { if (MosaSettings.Platform == "%DEFAULT%") + { MosaSettings.Platform = "%REGISTRY%"; + } openFileDialog.FileName = MosaSettings.GetRegistry(WindowsRegistry.LastOpened, null); } @@ -1086,6 +1088,7 @@ private void UpdateDisplay() "x86" => 0, "x64" => 1, "arm32" => 2, + //"arm64" => 3, _ => cbPlatform.SelectedIndex }; diff --git a/Source/Mosa.Tool.Launcher/MainWindow.axaml.cs b/Source/Mosa.Tool.Launcher/MainWindow.axaml.cs index cdc2d5647e..319d41bc85 100644 --- a/Source/Mosa.Tool.Launcher/MainWindow.axaml.cs +++ b/Source/Mosa.Tool.Launcher/MainWindow.axaml.cs @@ -253,6 +253,7 @@ private void UpdateGuiSettings() "x86" => 0, "x64" => 1, "arm32" => 2, + //"arm64" => 3, _ => PltCmb.SelectedIndex }; diff --git a/Source/Mosa.Utility.Configuration/MOSASettings.cs b/Source/Mosa.Utility.Configuration/MOSASettings.cs index 2a8e75f53d..7dc65367e0 100644 --- a/Source/Mosa.Utility.Configuration/MOSASettings.cs +++ b/Source/Mosa.Utility.Configuration/MOSASettings.cs @@ -29,7 +29,7 @@ public static class Constant #endregion Constants - public Settings Settings { get; } = new Settings(); + public readonly Settings Settings = new Settings(); #region Properties @@ -700,7 +700,6 @@ public int InitialStackLocation public MosaSettings() { - Settings = new Settings(); } public MosaSettings(Settings settings) @@ -829,6 +828,14 @@ public void NormalizeSettings() Emulator = ToLower(Emulator); Platform = ToLower(Platform); LinkerFormat = ToLower(LinkerFormat); + + switch (Platform.ToLowerInvariant()) + { + case "x86": Platform = "x86"; break; + case "x64": Platform = "x64"; break; + case "arm32": Platform = "ARM32"; break; + case "arm64": Platform = "ARM64"; break; + } } private string ToLower(string value) @@ -986,21 +993,10 @@ public void ResolveFileAndPathSettings() { switch (Platform.ToLowerInvariant()) { - case "x86": - InitialStackLocation = Constant.X86StackLocation; - break; - - case "x64": - InitialStackLocation = Constant.X64StackLocation; - break; - - case "arm32": - InitialStackLocation = Constant.ARM32StackLocation; - break; - - case "arm64": - InitialStackLocation = Constant.ARM64StackLocation; - break; + case "x86": InitialStackLocation = Constant.X86StackLocation; break; + case "x64": InitialStackLocation = Constant.X64StackLocation; break; + case "arm32": InitialStackLocation = Constant.ARM32StackLocation; break; + case "arm64": InitialStackLocation = Constant.ARM64StackLocation; break; } } } diff --git a/Source/Mosa.Utility.Launcher/Starter.cs b/Source/Mosa.Utility.Launcher/Starter.cs index 86bda93f8b..95ae4fea5a 100644 --- a/Source/Mosa.Utility.Launcher/Starter.cs +++ b/Source/Mosa.Utility.Launcher/Starter.cs @@ -274,7 +274,7 @@ private Process LaunchQemu() arg.Append(" -cpu qemu64,+sse4.1,abm,bmi1,bmi2,popcnt"); break; } - case "ARM32": + case "arm32": { qemuApp = MosaSettings.QemuARM32App; qemuUefi = MosaSettings.QemuEdk2ARM32;