Skip to content

Commit

Permalink
X# launch.
Browse files Browse the repository at this point in the history
  • Loading branch information
jp2masa committed Aug 29, 2017
1 parent c0d4f4b commit bdb956d
Show file tree
Hide file tree
Showing 19 changed files with 1,322 additions and 16 deletions.
9 changes: 9 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
94 changes: 94 additions & 0 deletions source/XSharp.Build/Enums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Reflection;

namespace XSharp.Build
{
public enum DeploymentType
{
[Description("ISO Image")]
ISO,
[Description("USB Device")]
USB,
[Description("PXE Network Boot")]
PXE,
BinaryImage
}

public enum LaunchType
{
[Description("None")]
None,
[Description("VMware")]
VMware,
[Description("Attached Slave (CanaKit)")]
Slave,
[Description("Bochs")]
Bochs,
[Description("Intel Edison")]
IntelEdison,
[Description("Hyper-V")]
HyperV
}

public enum VMwareEdition
{
Workstation,
Player
}

public enum Architecture
{
x86 //, x64
}

public enum Framework
{
[Description("Microsoft .NET")]
MicrosoftNET,
Mono
}

public enum LogSeverityEnum : byte
{
Warning = 0,
Error = 1,
Informational = 2,
Performance = 3
}

public enum TraceAssemblies
{
None = 0,
User = 1,
Cosmos = 2,
All = 3
};

public enum DebugMode
{
IL,
Source
}

public enum StackCorruptionDetectionLevel
{
[Description("All Instructions")]
AllInstructions,
[Description("Method Footers Only")]
MethodFooters
}

public static class EnumHelper
{
public static string GetDescription(this Enum value)
{
FieldInfo field = value.GetType().GetRuntimeField(value.ToString());
DescriptionAttribute attribute = field.GetCustomAttribute<DescriptionAttribute>();
return attribute == null ? value.ToString() : attribute.Description;
}
}
}
73 changes: 73 additions & 0 deletions source/XSharp.Build/Launch/Bochs.Configuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;

namespace XSharp.Build.Launch
{
public partial class Bochs
{
private Dictionary<string, string> defaultConfigs = new Dictionary<string, string>();

private string mDefaultConfiguration;
protected string DefaultConfiguration
{
get
{
if (mDefaultConfiguration == null)
{
mDefaultConfiguration = GetDefaultConfiguration();
}

return mDefaultConfiguration;
}
}

private void GenerateConfiguration(string aFilePath)
{
var xConfiguration = DefaultConfiguration;

xConfiguration = xConfiguration.Replace("$DISPLAY_LIBRARY$", DisplayLibrary);
xConfiguration = xConfiguration.Replace("$DISPLAY_LIBRARY_OPTIONS$", GetDisplayLibraryOptionsAsString());
xConfiguration = xConfiguration.Replace("$DEBUG_SYMBOLS_PATH$", mDebugSymbolsPath);
xConfiguration = xConfiguration.Replace("$ROM_IMAGE$", Path.Combine(mBochsDirectory, "BIOS-bochs-latest"));
xConfiguration = xConfiguration.Replace("$VGA_ROM_IMAGE$", Path.Combine(mBochsDirectory, "VGABIOS-lgpl-latest"));
xConfiguration = xConfiguration.Replace("$CDROM_BOOT_PATH", mIsoFile);
xConfiguration = xConfiguration.Replace("$HARD_DISK_PATH", mHardDiskFile);
xConfiguration = xConfiguration.Replace("$PIPE_SERVER_NAME", mPipeServerName);

using (var xStream = File.Create(aFilePath))
{
using (var xWriter = new StreamWriter(xStream))
{
xWriter.WriteAsync(xConfiguration);
}
}
}

/// <summary>
/// Reads the Bochs configuration file from manifest and returns it.
/// </summary>
/// <returns>Returns the Bochs configuration file.</returns>
private string GetDefaultConfiguration()
{
var xConfiguration = "";

using (var xStream = GetType().Assembly.GetManifestResourceStream(GetType(), "Cosmos.bxrc"))
{
using (var xReader = new StreamReader(xStream))
{
xConfiguration = xReader.ReadToEnd();
}
}

return xConfiguration;
}

private string GetDisplayLibraryOptionsAsString()
{
return mDisplayLibraryOptions.ToString().ToLower().Replace("guidebug", "gui_debug");
}
}
}
Loading

0 comments on commit bdb956d

Please sign in to comment.